我正在做一个与献血有关的项目,这是我的搜索框架,任何人都可以搜索血液是否可用。 问题是我有两个名为user_don的表,其中保存了最后一次捐赠的入场号和日月年,以及保存了入场号码名称等等的name_don_det。 我想从两个表中检索数据,并使用向量或其他内容一起显示它。这就是我所知道的:
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)
答案 0 :(得分:0)
错误已解决.. 使用IN而不是=