users@glassfish.java.net

JDBC Connection Pooling does not correctly close statements, causing

From: <forums_at_java.net>
Date: Tue, 28 Jun 2011 05:43:35 -0500 (CDT)

Using a web application, on GlassFish 3.1, that open different connections
and associated preparedStatement, I've encountered the issue ORA-01000 as
described in the subject.

The main problem is that the same webapp works perfectly in the three
following scenarios:

1) deployed in OC4J using its jdbc connection pooling features as documented
in the following snippest:

ic = new InitialContext();

ds = (DataSource) ic.lookup("jdbc/myPooledDS");

...

Connection conn = ds.getConnection();

2) deployed in Glassfish using straight JDBC connection instead of Glassfish
connection pooling as documented in the following snippest:

conn =
DriverManager.getConnection("jdbc:oracle:thin:@myserver:1521:orcl","user","password"); 

3) deployed in Glassfish using OracleDataSource programmatically invoked
instead of Glassfish connection pooling as documented in the following
snippest:

ods = new OracleDataSource();

java.util.Properties prop = new java.util.Properties();

prop.setProperty("MinLimit", "0");

prop.setProperty("MaxLimit", "8");

String url = "jdbc:oracle:thin:@myserver:1521:orcl";

ods.setURL(url);

ods.setUser("user");

ods.setPassword("password");

ods.setConnectionCachingEnabled(true); // be sure set to true

ods.setConnectionCacheProperties (prop);

...

...

Connection conn = ods.getConnection();

In addition, I believe that if the webapp does work in the previous 3
scenarios, I don't have any connections and statements leaks issues.

Anyway, after many tests, I've found the parameter
"max-connection-usage-count": the default value is 0. If set > 0, Glassfish
starts to close connections and associated statements after their reusage.

The online manual
(http://download.oracle.com/docs/cd/E18930_01/html/821-2417/giyil.html)
explains its meaning as follows:

"(optional) Specifies the number of times a connections is reused by the
pool, after which it is closed. A zero value disables this feature. By
limiting the maximum number of times a connection can be reused, you can
avoid statement leaks if the application does not close statements."

My questions, before moving from OC4J to Glassfish production environment,
are:

1) is it a normal behaviour for Glassfish to not close statements and
connection using default jdbc pooling parameter values ?

2) setting "max-connection-usage-count" parameter could be considered as a
workaround or a "good practice" for production environment ?

3) according to your experience, what is the "ratio" for setting the best
value for parameter "max-connection-usage-count" ?

3) is there another way to solve the issue ? Are there any other parameter
that I could consider ?

Thanks and best regards

 

 


--
[Message sent by forum member 'Albert_V']
View Post: http://forums.java.net/node/816670