More Javadoc fixes.

This commit is contained in:
Erik C. Thauvin 2004-03-17 23:35:36 +00:00
parent 122b14c8f4
commit ed19117078
3 changed files with 22 additions and 27 deletions

View file

@ -78,8 +78,8 @@ public class SimplePool implements Runnable {
* *
* @throws IOException If the pool cannot be created. * @throws IOException If the pool cannot be created.
*/ */
public SimplePool(String driver, String jdbcUrl, String user, public SimplePool(String driver, String jdbcUrl, String user, String password, int minConns, int maxConns,
String password, int minConns, int maxConns, double maxConnTime, int maxCheckoutSeconds) double maxConnTime, int maxCheckoutSeconds)
throws IOException { throws IOException {
this.connPool = new Connection[maxConns]; this.connPool = new Connection[maxConns];
@ -129,8 +129,7 @@ public class SimplePool implements Runnable {
break; break;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Attempt (" + String.valueOf(i) + log.error("Attempt (" + String.valueOf(i) + " of " + String.valueOf(dbLoop) +
" of " + String.valueOf(dbLoop) +
") failed to create new connections set at startup.", e); ") failed to create new connections set at startup.", e);
log.warn("Will try again in 15 seconds..."); log.warn("Will try again in 15 seconds...");
@ -197,15 +196,11 @@ public class SimplePool implements Runnable {
if (connStatus[i] > 0) { // In use, catch it next time! if (connStatus[i] > 0) { // In use, catch it next time!
// Check the time it's been checked out and recycle // Check the time it's been checked out and recycle
long timeInUse = System.currentTimeMillis() - long timeInUse = System.currentTimeMillis() - connLockTime[i];
connLockTime[i]; log.warn("Connection [" + i + "] in use for " + timeInUse + " ms.");
log.warn("Connection [" + i +
"] in use for " + timeInUse +
" ms.");
if (maxCheckoutMillis != 0) { if (maxCheckoutMillis != 0) {
if (timeInUse > maxCheckoutMillis) { if (timeInUse > maxCheckoutMillis) {
log.warn("Connection [" + log.warn("Connection [" + i + "] failed to be returned in time. Recycling...");
i + "] failed to be returned in time. Recycling...");
throw new SQLException(); throw new SQLException();
} }
} }
@ -237,7 +232,8 @@ public class SimplePool implements Runnable {
try { try {
connPool[i].close(); connPool[i].close();
} catch (SQLException e0) { } catch (SQLException e0) {
log.warn("Can't close connection [" + String.valueOf(i) + "]. Might have been closed already. Trying to recycle anyway...", e); log.warn("Can't close connection [" + String.valueOf(i) +
"]. Might have been closed already. Trying to recycle anyway...", e);
} }
try { try {
@ -303,8 +299,7 @@ public class SimplePool implements Runnable {
do { do {
synchronized (connStatus) { synchronized (connStatus) {
if ((connStatus[roundRobin] < 1) && if ((connStatus[roundRobin] < 1) && (!connPool[roundRobin].isClosed())) {
(!connPool[roundRobin].isClosed())) {
conn = connPool[roundRobin]; conn = connPool[roundRobin];
connStatus[roundRobin] = 1; connStatus[roundRobin] = 1;
connLockTime[roundRobin] = System.currentTimeMillis(); connLockTime[roundRobin] = System.currentTimeMillis();
@ -330,7 +325,6 @@ public class SimplePool implements Runnable {
} else { } else {
synchronized (this) { // Add new connections to the pool synchronized (this) { // Add new connections to the pool
if (currConnections < maxConns) { if (currConnections < maxConns) {
try { try {
createConn(currConnections); createConn(currConnections);
currConnections++; currConnections++;
@ -346,8 +340,7 @@ public class SimplePool implements Runnable {
; ;
} }
log.debug("Connections Exhausted. Will wait and try again in loop " + log.debug("Connections Exhausted. Will wait and try again in loop " + String.valueOf(outerloop));
String.valueOf(outerloop));
} }
} // End of try 10 times loop } // End of try 10 times loop
@ -356,8 +349,7 @@ public class SimplePool implements Runnable {
log.debug("Unsuccessful getConnection() request during destroy()"); log.debug("Unsuccessful getConnection() request during destroy()");
} // End if(available) } // End if(available)
log.debug("Handing out connection [" + log.debug("Handing out connection [" + idOfConnection(conn) + "]: " +
idOfConnection(conn) + "]: " +
(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a")).format(new Date())); (new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a")).format(new Date()));
return conn; return conn;
@ -444,8 +436,7 @@ public class SimplePool implements Runnable {
log.debug("Error creating connection. The driver could not be loaded.", e2); log.debug("Error creating connection. The driver could not be loaded.", e2);
} }
log.debug("Opening connection [" + String.valueOf(i) + log.debug("Opening connection [" + String.valueOf(i) + "]: " + connPool[i].toString());
"]: " + connPool[i].toString());
} }
/** /**
@ -520,7 +511,8 @@ public class SimplePool implements Runnable {
if (useCount > 0) { if (useCount > 0) {
//bt-test successful //bt-test successful
String msg = "Unsafe shutdown: Had to close " + useCount + " active DB connections after " + millis + "ms."; String msg = "Unsafe shutdown: Had to close " + useCount + " active DB connections after " + millis +
"ms.";
log.error(msg); log.error(msg);
// Throwing following Exception is essential because servlet authors // Throwing following Exception is essential because servlet authors
// are likely to have their own error logging requirements. // are likely to have their own error logging requirements.

View file

@ -276,7 +276,8 @@ public class SimplePoolConnection implements Connection {
/** /**
* See {@link java.sql.Connection#prepareCall(String, int, int, int)}. * See {@link java.sql.Connection#prepareCall(String, int, int, int)}.
*/ */
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability)
throws SQLException { throws SQLException {
return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
} }
@ -308,7 +309,8 @@ public class SimplePoolConnection implements Connection {
/** /**
* See {@link java.sql.Connection#prepareStatement(String, int, int, int)}. * See {@link java.sql.Connection#prepareStatement(String, int, int, int)}.
*/ */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability)
throws SQLException { throws SQLException {
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
} }

View file

@ -76,7 +76,8 @@ public class SimplePoolServlet extends HttpServlet {
* The required intialization parameters are: * The required intialization parameters are:
* <p/> * <p/>
* <ul> * <ul>
* <li><code>varName</code> &ndash; Name of the variable used to hold a reference to the {@link SimplePoolDataSource}.</li> * <li><code>varName</code> &ndash; Name of the variable used to hold a reference to the
* {@link SimplePoolDataSource}.</li>
* <li><code>driver</code> &ndash; JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'</li> * <li><code>driver</code> &ndash; JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'</li>
* <li><code>jdbcUrl</code> &ndash; JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'</li> * <li><code>jdbcUrl</code> &ndash; JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'</li>
* <li><code>user</code> &ndash; Database login name. e.g. 'Scott'</li> * <li><code>user</code> &ndash; Database login name. e.g. 'Scott'</li>
@ -103,8 +104,8 @@ public class SimplePoolServlet extends HttpServlet {
String maxConnTime = servletConfig.getInitParameter("maxConnTime"); String maxConnTime = servletConfig.getInitParameter("maxConnTime");
String maxCheckoutSeconds = servletConfig.getInitParameter("maxCheckoutSeconds"); String maxCheckoutSeconds = servletConfig.getInitParameter("maxCheckoutSeconds");
if (isValid(varName) && isValid(driver) && isValid(jdbcUrl) && (user != null) && (password != null) && if (isValid(varName) && isValid(driver) && isValid(jdbcUrl) && (user != null) && (password != null)
isValid(minConns) && isValid(maxConns) && isValid(maxConnTime) && isValid(maxCheckoutSeconds)) { && isValid(minConns) && isValid(maxConns) && isValid(maxConnTime) && isValid(maxCheckoutSeconds)) {
dataSource = new SimplePoolDataSource(); dataSource = new SimplePoolDataSource();
dataSource.setDriver(driver); dataSource.setDriver(driver);