ASF Bugzilla – Attachment 27125 Details for
Bug 51264
Context/Manager/Store configuration proposal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
return pooled connections as early as poosible
jdbcstore-pooled-usage.diff (text/plain), 4.41 KB, created by
Felix Schumacher
on 2011-06-07 13:28:44 UTC
(
hide
)
Description:
return pooled connections as early as poosible
Filename:
MIME Type:
Creator:
Felix Schumacher
Created:
2011-06-07 13:28:44 UTC
Size:
4.41 KB
patch
obsolete
>diff --git a/java/org/apache/catalina/session/JDBCStore.java b/java/org/apache/catalina/session/JDBCStore.java >index 7580c2b..a9d0cc4 100644 >--- a/java/org/apache/catalina/session/JDBCStore.java >+++ b/java/org/apache/catalina/session/JDBCStore.java >@@ -874,11 +874,13 @@ public class JDBCStore extends StoreBase { > * @return <code>Connection</code> if the connection succeeded > */ > protected Connection getConnection() { >+ Connection _conn = null; > try { >- if (dbConnection == null || dbConnection.isClosed()) { >+ _conn = open(); >+ if (_conn == null || _conn.isClosed()) { > manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBClosed")); >- open(); >- if (dbConnection == null || dbConnection.isClosed()) { >+ _conn = open(); >+ if (_conn == null || _conn.isClosed()) { > manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBReOpenFail")); > } > } >@@ -887,7 +889,7 @@ public class JDBCStore extends StoreBase { > ex.toString())); > } > >- return dbConnection; >+ return _conn; > } > > /** >@@ -916,8 +918,8 @@ public class JDBCStore extends StoreBase { > } > > if (dataSource != null) { >- dbConnection = dataSource.getConnection(); >- return dbConnection; >+ Connection _conn = dataSource.getConnection(); >+ return _conn; > } > > // Instantiate our database driver if necessary >@@ -1014,13 +1016,15 @@ public class JDBCStore extends StoreBase { > } > > /** >- * Release the connection, not needed here since the >- * connection is not associated with a connection pool. >+ * Release the connection, if it >+ * is associated with a connection pool. > * > * @param conn The connection to be released > */ > protected void release(Connection conn) { >- // NOOP >+ if (dataSource != null) { >+ close(conn); >+ } > } > > /** >@@ -1034,7 +1038,13 @@ public class JDBCStore extends StoreBase { > protected synchronized void startInternal() throws LifecycleException { > > // Open connection to the database >- this.dbConnection = getConnection(); >+ Connection _conn = getConnection(); >+ if (dataSource != null) { >+ // if connection was created by a dataSource, we will release it >+ close(_conn); >+ } else { >+ this.dbConnection = _conn; >+ } > > super.startInternal(); > } >diff --git a/java/org/apache/catalina/session/LocalStrings.properties b/java/org/apache/catalina/session/LocalStrings.properties >index b16f942..f7f6a6d 100644 >--- a/java/org/apache/catalina/session/LocalStrings.properties >+++ b/java/org/apache/catalina/session/LocalStrings.properties >@@ -27,7 +27,7 @@ JDBCStore.checkConnectionDBClosed=The database connection is null or was found t > JDBCStore.checkConnectionDBReOpenFail=The re-open on the database failed. The database could be down. > JDBCStore.checkConnectionSQLException=A SQL exception occurred {0} > JDBCStore.checkConnectionClassNotFoundException=JDBC driver class not found {0} >-JDBCStore.wrongDataSource=Can't open JNDI DataSource [{0}] >+JDBCStore.wrongDataSource=Can not open JNDI DataSource [{0}] > JDBCStore.missingDataSourceName=No valid JNDI name was given. > managerBase.createRandom=Created random number generator for session ID generation in {0}ms. > managerBase.createSession.ise=createSession: Too many active sessions >diff --git a/webapps/docs/config/manager.xml b/webapps/docs/config/manager.xml >index f5b6bdc..2b9835e 100644 >--- a/webapps/docs/config/manager.xml >+++ b/webapps/docs/config/manager.xml >@@ -360,7 +360,10 @@ > <p>Name of the JNDI resource for a JDBC DataSource-factory. If this option > is given and a valid JDBC resource can be found, it will be used and any > direct configuration of a JDBC connection via <code>connectionURL</code> >- and <code>driverName</code> will be ignored.</p> >+ and <code>driverName</code> will be ignored. Since this code uses prepared >+ statements, you might want to configure pooled prepared statements as >+ shown in <a href="../jndi-resources-howto.html">the JNDI resources >+ HOW-TO</a>.</p> > </attribute> > > <attribute name="driverName" required="true">
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51264
:
27084
|
27125
|
27127