This patch logs the exception from DriverManager.getConnection(). The
current code assumes (why?) that it should never happen.
For example, it may happen if there are incorrect security privileges, and
the user is not running with PHOENIX_SECURE=false.
I am resubmitting this patch because it wasn't included in the most recent
CVS update of the file, and CVS reported merge conflicts.
--- Noel
Index: JdbcDataSource.java
===================================================================
RCS file:
/home/cvspublic/jakarta-james/src/java/org/apache/james/util/mordred/JdbcDataSource.java,v
retrieving revision 1.8
diff -u -r1.8 JdbcDataSource.java
--- JdbcDataSource.java 20 Jun 2002 22:04:14 -0000 1.8
+++ JdbcDataSource.java 20 Jun 2002 22:56:09 -0000
@@ -246,6 +246,57 @@
/**
* Need to clean up all connections
*/
+<<<<<<< JdbcDataSource.java
+ private PoolConnEntry createConn() throws SQLException {
+ PoolConnEntry entry = null;
+
+ synchronized (this) {
+ if (connCreationsInProgress > 0) {
+ //We are already creating one in another place
+ return null;
+ }
+
+ long now = System.currentTimeMillis();
+ if (now - connLastCreated < 1000 * pool.size()) {
+ //We don't want to scale up too quickly...
+ if (DEEP_DEBUG) {
+ System.err.println("We don't want to scale up too quickly");
+ }
+ return null;
+ }
+
+ if (maxConn == 0 || pool.size() < maxConn) {
+ connCreationsInProgress++;
+ connLastCreated = now;
+ } else {
+ // We've already hit a limit... fail silently
+ getLogger().debug("Connection limit hit... " + pool.size() + " in
+pool and " + connCreationsInProgress + " + on the way.");
+ return null;
+ }
+ }
+
+ try {
+ entry = new PoolConnEntry(this,
+ java.sql.DriverManager.getConnection(jdbcURL, jdbcUsername,
+jdbcPassword),
+ ++connectionCount);
+ getLogger().debug("Opening connection " + entry);
+ entry.lock();
+ pool.addElement(entry);
+ return entry;
+ } catch (SQLException sqle) {
+ // Exception from DriverManager.getConnection() - log it, and return null
+ StringWriter sout = new StringWriter();
+ PrintWriter pout = new PrintWriter(sout, true);
+ pout.println("Error creating connection: ");
+ sqle.printStackTrace(pout);
+ getLogger().error(sout.toString());
+ return null;
+ } finally {
+ synchronized (this) {
+ connCreationsInProgress--;
+ }
+
+=======
public void dispose() {
// Stop the background monitoring thread
if(reaper != null) {
@@ -253,6 +304,7 @@
//In case it's sleeping, help it quit faster
reaper.interrupt();
reaper = null;
+>>>>>>> 1.8
}
// The various entries will finalize themselves once the reference
// is removed, so no need to do it here
@@ -417,7 +469,12 @@
pool.addElement(entry);
return entry;
} catch(SQLException sqle) {
- //Shouldn't ever happen, but it did, just return null.
+ // Exception from DriverManager.getConnection() - log it, and return null
+ StringWriter sout = new StringWriter();
+ PrintWriter pout = new PrintWriter(sout, true);
+ pout.println("Error creating connection: ");
+ sqle.printStackTrace(pout);
+ getLogger().error(sout.toString());
return null;
} finally {
synchronized(this) {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>