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();
}*
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 = ?;";
Why your statement is initialized as ResultSet.CONCUR_UPDATABLE?
Is your connection autocommit=false?
Last edit: Marco Amadei 2015-08-02