0
我正在做一個與獻血有關的項目,這是我的搜索框架,任何人都可以搜索血液是否可用。 問題是我有兩張名爲user_don的表,其中保存了最後一次捐款的入場號和日月份年份,以及保存了入場號碼姓名電話等的name_don_det。 我想從兩個表中檢索數據並顯示在同一時間使用矢量或別的東西一起。這是我所:在netbeans中使用向量填充表
user_view(String d1, String d2, String d3) throws ClassNotFoundException, SQLException {
initComponents();
int a = Integer.parseInt(d1);
int b = Integer.parseInt(d2);
int c = Integer.parseInt(d3);
int year=a;
int month=b;
int date=c;
String query;
String query1;
if(b<=6)
{
year=a-1;
month=b+6;
query="Select * from user_don_det where Year<="+ year +" and Month<="+ month +"";
query1="SELECT * FROM `user_det` WHERE `Admission`=(Select Admission From user_don_det where Year<="+ year +" and Month<="+ month +")";
}
else
{
month=b-6;
query="Select * from user_don_det where Month<="+ month +" or Year<="+ year +"";
query1="SELECT * FROM `user_det` WHERE `Admission`=(Select Admission From user_don_det where Month<="+ month +")";
}
blooddonation.dbconnectivity db=new blooddonation.dbconnectivity();
ResultSet rs=db.q_execute(query);
ResultSet rs1=db.q_execute(query1);
Vector data=new Vector();
while(rs.next())
{
Vector row=new Vector();
row.addElement(rs.getInt(1));
row.addElement(rs.getInt(2));
row.addElement(rs.getInt(3));
row.addElement(rs.getInt(4));
data.addElement(row);
}
while(rs1.next())
{Vector row=new Vector();
row.addElement(rs1.getString(1));
row.addElement(rs1.getString(2));
row.addElement(rs1.getString(6));
row.addElement(rs1.getInt(8));
data.addElement(row);
}
Vector head=new Vector();
head.addElement("Admission No");
head.addElement("Date");
head.addElement("Month");
head.addElement("Year");
head.addElement("Name");
head.addElement("Email");
head.addElement("Sex");
head.addElement("Phone");
DefaultTableModel model=new DefaultTableModel(data,head);
tab.setModel(model);
}
這是當前的錯誤狀態:
SEVERE: null
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:804)
at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6986)
at blooddonation.user_view.<init>(user_view.java:55)
at blooddonation.user_fscreen$5.actionPerformed(user_fscreen.java:263)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
哪行'user_view.java:55'?發佈[MCVE]:發佈最低限額以顯示您的問題。 (寫一個最簡單的案例是一個很好的調試技巧,這樣做很可能解決你的問題。) – c0der