Troubleshooting
Problem
JDBC Statement objects must always be closed by the application instead of allowing them to be closed by garbage collection.
Resolving The Problem
JDBC Statement objects must always be explicitly closed by calling the close method on the object. This also applies to the PreparedStatement and CallableStatement objects. It is a poor programming practice to rely on garbage collection to collect the statement object. This is especially true when connection pooling is used because the underlying connection object can stay open for an extended length of time.
IBM Toolbox for Java JDBC Driver
The toolbox JDBC driver requires that statements be explicitly closed. With the current design, the connection object holds a reference to all statement objects. The statement objects cannot be reclaimed until the connection is closed. If an application allows a statement object to go out of scope without explicitly closing it, the resources associated with the statement are "leaked". This leads to a steady increase in memory use on the client and server and a degradation in performance. The application eventually fails with an out of resource error message. The toolbox statement limit is 9999 statements per connection (APAR SA89583). A large amount of resources can be consumed before the job eventually fails.
IBM Developer Kit for Java JDBC Driver ("Native")
The native JDBC driver uses weak references to statement objects it generates. Although this allows statement objects to be garbage collected it is still recommended that applications close all statements explicitly. Failure to do so results in decreased performance. Depending on how often Garbage Collection is run, it is still possible for an application to run out of handles.
IBM Developer Kit for Java Documentation
The performance tips for the IBM Developer Kit for Java address explicitly closing JDBC resources when no longer in use. See the documentation here.
IBM Toolbox for Java JDBC Driver
The toolbox JDBC driver requires that statements be explicitly closed. With the current design, the connection object holds a reference to all statement objects. The statement objects cannot be reclaimed until the connection is closed. If an application allows a statement object to go out of scope without explicitly closing it, the resources associated with the statement are "leaked". This leads to a steady increase in memory use on the client and server and a degradation in performance. The application eventually fails with an out of resource error message. The toolbox statement limit is 9999 statements per connection (APAR SA89583). A large amount of resources can be consumed before the job eventually fails.
IBM Developer Kit for Java JDBC Driver ("Native")
The native JDBC driver uses weak references to statement objects it generates. Although this allows statement objects to be garbage collected it is still recommended that applications close all statements explicitly. Failure to do so results in decreased performance. Depending on how often Garbage Collection is run, it is still possible for an application to run out of handles.
IBM Developer Kit for Java Documentation
The performance tips for the IBM Developer Kit for Java address explicitly closing JDBC resources when no longer in use. See the documentation here.
[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Data Access","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Historical Number
23860552
Was this topic helpful?
Document Information
More support for:
IBM i
Software version:
Version Independent
Operating system(s):
IBM i
Document number:
640989
Modified date:
01 January 2020
UID
nas8N1017295
Manage My Notification Subscriptions