Quantcast
Channel: SCN : Popular Discussions - SAP Crystal Reports, version for Eclipse
Viewing all articles
Browse latest Browse all 893

Database connection not closed

$
0
0

Hello,

 

Synopsis:

We are seeing an issue where the database connection used by Crystal Reports is not being closed when a report is generated. Eventually, the connection pool is used up and no more reports can be run.

 

Has anyone a work around, are we not specifying something correctly, or can we request a library fix for this issue?

 

Detail:

- We are using Crystal Reports Java Runtime Component (v2.2.218) as a module on JBoss EAP 6.3

- An EJB is used to generate a report and return the PDF to a user.

- Crystal Reports is set up to use JNDI to get a database connection.

- After report is generated and report closed, the connection pool has one less available connection, and 1 used connection

- Report code is something like this:

 

// Open report

ReportClientDocument reportClientDocument = new ReportClientDocument();

reportClientDocument.open(...);

 

// Set some report parameters

...

 

// Export report

reportClientDocument.getPrintOutputController().export(...);

 

// Close report

reportClientDocument.close();

 

- We noticed that the JBoss database connection pool was slowly getting depleted.

- To debug, we enabled the debugging in the cache connection manager in JBoss which will check for DB connections that have not been closed, and will log the offending class that opened the connection (note: it is not recommended to leave this on in production code) (more detail here: https://developer.jboss.org/wiki/DetectingAndClosingLeakedConnectionsInJBoss71 and here: https://access.redhat.com/solutions/17782 )

- Indeed, the connection is opened by Crystal Reports, but not closed:

 

16:09:58.541 INFO [org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager] (EJB default -7)

IJ000100: Closing a connection for you. Please close them yourself: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@466a2070:

java.lang.Throwable: STACKTRACE

at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.registerConnection(CachedConnectionManagerImpl.java:269)       

at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:519)       

at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:143)

at com.crystalsdecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(Unknown Source) [DatabaseConnectors.jar:12.2.218.2374]

at com.crystalsdecisions.reports.queryengine.JDBConnectionWrapper.Open(SourceFile:123) [CrystalReportsRuntime.jar:12.2.218.2374]

at com.crystalsdecisions.reports.queryengine.br.Open(SourceFile:1786) [CrystalReportsRuntime.jar:12.2.218.2374]

(...continued as obfuscated code)

 

- It seems the class opening the connection also has a close() method, however, it is not called by Crystal Reports.

- We tried calling close manually on the DB controller and IConnection, but received an unimplemented exception in both instances (admittedly, they are for internal use, but we are clutching for solutions)

 

DatabaseController dbController = reportClientDocument.getDatabaseController();

Connections connections =  reportClientDocument.getDatabase().getConnections();

dbController .closeConnection(connections.get(0)); // <-- Exception

Connections.get(0).close(); // <-- Exception

 

11:05:07.372 SEVERE [...reportingClass] (EJB default-3) null; com.crystaldecisions.sdk.occa.report.lib.ReportSDKException:

Currently not implemented in the Java Reporting Component ---- Error code:-21472137395 Error code name: serverProgrammingError

 

 

Possible solutions:

1. Fix the Crystal Reports java library to properly close the database connection

2. (Hack) - Allow an existing connection (java.sql.connection) to be passed in that can be manually closed (Others have asked this question, but the discussions remain unanswered, see here: http://scn.sap.com/thread/1851980and here: http://scn.sap.com/thread/1827266 )


Viewing all articles
Browse latest Browse all 893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>