-1

我正在尝试使用最后添加的字符串执行查询..我无法做到这一点,resultset所以我尝试preparedstatement我能够插入查询..但无法得到它的结果:(请帮助我。这是我的示例代码

PreparedStatement pstm;
String query= "SELECT C.name, C.searchkey, F.product, 
                F.lastsoldqty, F.consumption, F.lastsaledate,F.deliverydate,
                F.remainderdate, F.remark1, F.remark2, F.stock, F.invoiceno, 
                F.id FROM followup F,customers C where C.ID=F.CUST_ID 
                AND C.searchkey= ?";
         pstm= connection.prepareStatement(query);
         pstm.setString(1, number);
         pstm.executeQuery();
      //   System.out.println("executed");
         java.sql.ResultSetMetaData rsmd1 = pstm.getMetaData();
         int colNo = rsmd1.getColumnCount();       
         DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
         int rowCount = model.getRowCount(); 
         for(int i = rowCount -1; i >= 0; --i) { model.removeRow(i); } 

          while(pstm.next())   //im getting error here cant find method .next in pstm
             {

                  Object[] objects = new Object[colNo];
                 for(int i=0;i<colNo;i++){

                         objects[i]=rs.getObject(i+1);

                 }                  
                 model.addRow(objects);

             }
4

1 回答 1

2

熟悉javadoc

该方法是为notnext定义的。利用ResultSetPreparedStatement

ResultSet resultSet = pstm.executeQuery();

然后

while (resultSet.next()) 
于 2013-09-13T14:33:14.290 回答