New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening new PreparedStatement will close opened ResultSet (in AUTOCOMMIT mode) [JDBC304] #350
Comments
Modified by: @mrotteveelsecurity: Developers [ 10012 ] => |
Commented by: @mrotteveel This behaviour is identical to the behaviour in Jaybird 2.1.6. It is also the behavior implied / specified by the JDBC specification: In the Javadoc of Connection.setAutoCommit(boolean): Chapter 15.2.5: When Jaybird creates a new statement in autocommit mode it does an implicit commit, therefor the ResultSet of the other Statement is closed. This behavior is also documented in chapter 6 of the Jaybird 2.1 JDBC driver manual: http://www.firebirdsql.org/file/documentation/drivers_documentation/Jaybird_2_1_JDBC_driver_manual.pdf For the behaviour you want, you need to explicitly create a ResultSet that is holdable over commit: Or you need to specify the connection property defaultHoldable=true Doing this has memory and performance implications for all ResultSet: the entire ResultSet is loaded into memory. |
Commented by: @mrotteveel Closed as 'Won't fix', described behaviour is not a bug but as designed. |
Commented by: Česnek Michal (cesnek) Yes teoretically by manual it work out, but in practice it does not. I will change my example code by your and driver manual council: //I get connection from connection poll. This connection is in autocommit mode. // it return: 'stmt' Holdability: true, but it return true also if I create a statement without any parameters! ResultSet rs = stmt1.executeQuery("SELECT table_name.column_name FROM table_name"); //This will return false - it is fine :-) //Calling this function internaly close result set "rs"!! But only in AUTOCOMMIT in transaction processing it work fine! //This will return true - it isnot fine :-( while (rs.next()) { In manual all works fine, but in practice it doesnot! |
Commented by: @mrotteveel What does ConnectionPoolManager.getConnection(); actually do? Are you sure you are directly using the Jaybird implementation, and not a proxy or wrapper provided by the connection pool? Because in that case, the proxy or wrapper might have its own logic. I did a quick test of my previous comment (with a Connection obtained through DriverManager) before, and the resultset wasn't being closed. |
Commented by: Česnek Michal (cesnek) I use DBPool, http://www.snaq.net/java/DBPool/. I will try to use with another Connection pool manager. |
Commented by: Česnek Michal (cesnek) OK so I try simplify my code to minimum and this is my pure test code without using any Connection Pool Managers:
STD-OUT: |
Commented by: @mrotteveel That looks a lot like what I tested. I will test it again and compare behaviour between your test and mine. For the time being I suggest you disable autocommit. |
Commented by: @mrotteveel I am able to reproduce the problem; my quick test just checked if rs.next() would throw an exception or not (and I assumed because it didn't that everything else was ok). The problem did not occur in 2.1.6. I will schedule it to be fixed for 2.2.3. |
Modified by: @mrotteveelFix Version: Jaybird 2.2.3 [ 10510 ] |
Modified by: @mrotteveel |
Commented by: @mrotteveel The behavior of holdable ResultSets was a bit weird in 2.1.6 as well (they were closed, but you could still scroll through them). I have created JDBC305 for the larger scope of problems with ResultSet behavior which might require a more thorough investigation and rewrite than just fixing the problem of this issue. |
Modified by: @mrotteveel |
Commented by: @mrotteveel Committed fix for this problem. I noticed some additional problems surrounding ResultSets (see JDBC305 and JDBC307), but fixes for that will have to wait until Jaybird 2.3 as it requires some radical changes that I am not prepared to do for 2.2.x. |
Modified by: @mrotteveelstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: Česnek Michal (cesnek)
Relate to JDBC305
Is related to JDBC209
From jaybird version 2.2 and up (2.2.1, 2.2.2) is now this BUG!
When I want in AUTOCOMMIT mode read data from opened ResultSet and in the same thread I open next PreparedStatement for inserting data, so calling function "prepareStatement" internaly close previously opened ResuldSet!
This BUG is only in AUTOCOMMIT mode in transaction processing it work fine!
Example writed code:
//I get connection from connection poll. This connection is in autocommit mode.
Connection conn = ConnectionPoolManager.getConnection();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt1.executeQuery("SELECT table_name.column_name FROM table_name");
//Calling this function internaly close result set "rs"!! But only in AUTOCOMMIT in transaction processing it work fine!
Statement stmt2 = conn.prepareStatement("INSERT INTO ...");
while (rs.next()) {
//reading data from "rs"
//writing data to "stmt2"
}
PLEASE HELP!
Commits: 3f98f54 a7df803 68fa2d2 72ff1fd FirebirdSQL/fbt-repository@84490d6 FirebirdSQL/fbt-repository@b689545 FirebirdSQL/fbt-repository@611977c FirebirdSQL/fbt-repository@005e6c5
The text was updated successfully, but these errors were encountered: