An exception is now returned when there are no free connections in the pool.

This commit is contained in:
Erik C. Thauvin 2004-03-30 02:10:16 +00:00
parent eef219d37e
commit dd8861d9f9
2 changed files with 14 additions and 8 deletions

View file

@ -1,7 +1,7 @@
/* /*
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePool.java,v $ * $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePool.java,v $
* $Revision: 1.1 $ * $Revision: 1.2 $
* $Date: 2004-03-28 02:04:57 $ * $Date: 2004-03-30 02:10:16 $
* *
* Copyright (c) 2002, Marc A. Mnich (http://www.javaexchange.com/) * Copyright (c) 2002, Marc A. Mnich (http://www.javaexchange.com/)
* All rights reserved. * All rights reserved.
@ -33,7 +33,7 @@ import java.util.Date;
* @author <a href="http://www.javaexchange.com/">Marc A. Mnich</a> * @author <a href="http://www.javaexchange.com/">Marc A. Mnich</a>
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a> * @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a> * @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
* @version $Revision: 1.1 $, $Date: 2004-03-28 02:04:57 $ * @version $Revision: 1.2 $, $Date: 2004-03-30 02:10:16 $
* @since 1.0 * @since 1.0
*/ */
public class SimplePool implements Runnable { public class SimplePool implements Runnable {
@ -398,9 +398,10 @@ public class SimplePool implements Runnable {
res = "freed " + conn.toString(); res = "freed " + conn.toString();
log.debug("Freed connection [" + String.valueOf(thisconn) + ']'); log.debug("Freed connection [" + String.valueOf(thisconn) + ']');
} else { } else {
log.error("Could not free connection [" + String.valueOf(thisconn) + ']'); log.error("Could not free connection.");
} }
return res; return res;
} }

View file

@ -1,7 +1,7 @@
/* /*
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java,v $ * $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java,v $
* $Revision: 1.1 $ * $Revision: 1.2 $
* $Date: 2004-03-28 02:04:57 $ * $Date: 2004-03-30 02:10:16 $
* *
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/) * Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
* All rights reserved. * All rights reserved.
@ -47,7 +47,7 @@ import java.util.Map;
* *
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a> * @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a> * @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
* @version $Revision: 1.1 $, $Date: 2004-03-28 02:04:57 $ * @version $Revision: 1.2 $, $Date: 2004-03-30 02:10:16 $
* @since 1.0 * @since 1.0
*/ */
public class SimplePoolConnection implements Connection { public class SimplePoolConnection implements Connection {
@ -60,9 +60,14 @@ public class SimplePoolConnection implements Connection {
* *
* @param pool The connection pool. * @param pool The connection pool.
*/ */
public SimplePoolConnection(SimplePool pool) { public SimplePoolConnection(SimplePool pool)
throws SQLException {
this.pool = pool; this.pool = pool;
conn = pool.getConnection(); conn = pool.getConnection();
if (conn == null)
{
throw new SQLException("No connections currently available in the pool.");
}
} }
/** /**