I use jdbc with mysql and use transcription. IN
while(resultset.hasnext()){}
while I pass the connection, my result set closes, and when the 2nd cycle loop repeats, it throws an exception that the operation cannot be performed on the closed result set. Although I also set these options
statement1 = connection1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
but I cannot keep the ResultSet open after commit.
while(resultSet.next()){
id=resultSet.getInt(1);
c1 = resultSet.getString(2);
c2 = resultSet.getDate(3);
c3 = resultSet.getString(4);
c4 = resultSet.getString(5);
c5 = resultSet.getString(6);
c6 = resultSet.getString(7);
c7 = resultSet.getString(8);
c8 = resultSet.getString(9);
c9 = resultSet.getString(10);
c10 = resultSet.getString(11);
c11 = resultSet.getString(12);
c12 = resultSet.getString(13);
c13 = resultSet.getString(14);
c14 = resultSet.getDate(15);
preparedStatement.setString(1, c1);
preparedStatement.setDate(2, c2);
preparedStatement.setString(3, c3);
preparedStatement.setString(4, c4);
preparedStatement.setString(5, c5);
preparedStatement.setString(6, c6);
preparedStatement.setString(7, c7);
preparedStatement.setString(8, c8);
preparedStatement.setString(9, c9);
preparedStatement.setString(10, c10);
preparedStatement.setString(11, c11);
preparedStatement.setString(12, c12);
preparedStatement.setString(13, c13);
preparedStatement.setDate(14, c14);
preparedStatement.executeUpdate();
query = "UPDATE abc SET isUpdated = 1 WHERE abc_id= "+id;
statement1.executeUpdate(query);
System.out.println("holdablity... "+resultSet.getHoldability());
connection1.commit();
System.out.println(connection1+"and result is====="+resultSet+" result status is "+resultSet.isClosed()+" connection1 is "+connection1.isClosed());
System.out.println("holdablity... "+resultSet.getHoldability());
connection2.commit();
System.out.println(connection1+"and result is====="+resultSet+" result status is "+resultSet.isClosed()+" connection2 is "+connection2.isClosed());
System.out.println("Data copied........");
}
source
share