Menu

Second time a select query runs program crashes

Help
2015-08-02
2015-08-02
  • Justin Wood

    Justin Wood - 2015-08-02

    I run a prepared statment to retreive a single row of data. The firt time it is exected all is fine but the second time I run the query everything just hangs. All my connections are closed after each query. Any help appreciated

    *private void setQuery(int complaintNumber) throws SQLException, IllegalStateException, ClassNotFoundException {
    String containActions = "SELECT tbld3ContainAct.CompNo, tbld3ContainAct.ContainActNo, tbld3ContainAct.DateContain as [DateContain], tbld3ContainAct.ContainCustQty as [Contained at Cust], tbld3ContainAct.ContainCustRejQty as [Rejected at Customer], tbld3ContainAct.ContainFGQty as [Contained at Supplier], tbld3ContainAct.ContainFGRejQty as [Rejected at Supplier]" +
    " FROM tbld3ContainAct" +
    " WHERE tbld3ContainAct.CompNo = ?;";

       ConnectDB db = new ConnectDB();
    
       PreparedStatement preparedStatement = db.ConnectDB().prepareStatement( containActions, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
    
       preparedStatement.setInt(1, complaintNumber);
    
       ResultSet resultSetInfo = preparedStatement.executeQuery(); // this is where it stops second time its called
    
       while (resultSetInfo.next()) {
            List<Object> list = new ArrayList<>();
            for (int i = 0; i < getColumnCount(); i++) {
                String string = resultSetInfo.getString(i+1);
                list.add(string);            
            }
      listOfLists.add(list);      
      }
      fireTableStructureChanged();
    
      resultSetInfo.close();                 
      preparedStatement.close();
      db.CloseDB();
    }*
    
     
  • Marco Amadei

    Marco Amadei - 2015-08-02

    Why your statement is initialized as ResultSet.CONCUR_UPDATABLE?
    Is your connection autocommit=false?

     

    Last edit: Marco Amadei 2015-08-02

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.