Skip to content
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

JDBC prepared statements aren't closed #2366

Open
DelusionalLogic opened this issue Feb 17, 2025 · 0 comments
Open

JDBC prepared statements aren't closed #2366

DelusionalLogic opened this issue Feb 17, 2025 · 0 comments

Comments

@DelusionalLogic
Copy link

Describe the bug
When persisting a bunch of objects, DB2 JCC runs out of prepared statement objects. Running with DB2 tracing enabled reveals that eclipselink isn't closing the statements it's preparing.

5.0.0-B06 produces the following trace.

[jcc][Connection@f7ec65] DB2 LUWID: 172.17.0.1.40032.250217114216.0536
[jcc][Time:2025-02-17-12:41:39.430][Thread:com.example.App.main()][Connection@f7ec65]commit () returned null
[jcc][Time:2025-02-17-12:41:39.430][Thread:com.example.App.main()][Connection@f7ec65]setAutoCommit (true) called
[jcc][Time:2025-02-17-12:41:39.430][Thread:com.example.App.main()][Connection@f7ec65]setAutoCommit (false) called
[jcc][Time:2025-02-17-12:41:39.430][Thread:com.example.App.main()][Connection@f7ec65]prepareStatement (INSERT INTO Entity (VALUE) VALUES (?), 1) called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][Connection@f7ec65]prepareStatement () returned com.ibm.db2.jcc.am.bq@26923e7c
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]setLong (1, 1337) called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]executeUpdate () called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]stmt_bidiTransform (select ID from final table (INSERT INTO Entity (VALUE) VALUES (?))) called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]stmt_bidiTransform not enabled (select ID from final table (INSERT INTO Entity (VALUE) VALUES (?))) called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]executeUpdate () returned 1
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]getGeneratedKeys () called
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][PreparedStatement@26923e7c]getGeneratedKeys () returned ResultSet@19eae7f8
[jcc][Time:2025-02-17-12:41:39.431][Thread:com.example.App.main()][Connection@f7ec65]commit () called
[jcc][Connection@f7ec65] DB2 LUWID: 172.17.0.1.40032.250217114216.0537

Where 3.0.4 (the last version I could find that worked) did close the statements.

jcc][Connection@599479c6] DB2 LUWID: 172.17.0.1.36346.250217114256.0641
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][Connection@599479c6]commit () returned null
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][Connection@599479c6]setAutoCommit (true) called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][Connection@599479c6]setAutoCommit (false) called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][Connection@599479c6]prepareStatement (INSERT INTO Entity (VALUE) VALUES (?)) called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][Connection@599479c6]prepareStatement () returned com.ibm.db2.jcc.am.bq@548515e1
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][PreparedStatement@548515e1]setLong (1, 1337) called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][PreparedStatement@548515e1]executeUpdate () called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][PreparedStatement@548515e1]stmt_bidiTransform (INSERT INTO Entity (VALUE) VALUES (?)) called
[jcc][Time:2025-02-17-12:42:26.153][Thread:com.example.App.main()][PreparedStatement@548515e1]stmt_bidiTransform not enabled (INSERT INTO Entity (VALUE) VALUES (?)) called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@548515e1]executeUpdate () returned 1
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@548515e1]close () called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][Connection@599479c6]prepareStatement (SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1) called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][Connection@599479c6]prepareStatement () returned com.ibm.db2.jcc.am.bq@7c7db9b7
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@7c7db9b7]executeQuery () called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@7c7db9b7]stmt_bidiTransform (SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1) called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@7c7db9b7]stmt_bidiTransform not enabled (SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1) called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@7c7db9b7]executeQuery () returned com.ibm.db2.jcc.t4.h@5e8b4810
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][PreparedStatement@7c7db9b7]close () called
[jcc][Time:2025-02-17-12:42:26.154][Thread:com.example.App.main()][Connection@599479c6]commit () called
[jcc][Connection@599479c6] DB2 LUWID: 172.17.0.1.36346.250217114256.0642

To Reproduce
I've made a reproduction project available. You'll need to bring your own database and db2jcc driver. I've made use of an internal mirror.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant