在netbeans中使用Vector填充表



我正在做一个与献血有关的项目,这是我的搜索框架,任何人都可以搜索血液是否可用。问题是,我有两个名为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)

错误已解决。IN要代替=

相关内容

  • 没有找到相关文章

最新更新