diff --git a/src/net/java/dev/simplepool/SimplePool.java b/src/net/java/dev/simplepool/SimplePool.java
index d359340..e03999e 100644
--- a/src/net/java/dev/simplepool/SimplePool.java
+++ b/src/net/java/dev/simplepool/SimplePool.java
@@ -64,7 +64,7 @@ public class SimplePool implements Runnable {
/**
- * Creates a new Connection Broker.
+ * Creates a new Connection Pool.
*
* @param driver JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'
* @param jdbcUrl JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'
@@ -75,6 +75,8 @@ public class SimplePool implements Runnable {
* @param maxConnTime Time in days between connection resets. (Reset does a basic cleanup)
* @param maxCheckoutSeconds Max time a connection can be checked out before being recycled. Zero value turns option
* off, default is 60 seconds.
+ *
+ * @throws IOException If the pool cannot be created.
*/
public SimplePool(String driver, String jdbcUrl, String user,
String password, int minConns, int maxConns, double maxConnTime, int maxCheckoutSeconds)
@@ -280,6 +282,8 @@ public class SimplePool implements Runnable {
* If the min number of threads are ever exhausted, new threads are added up the the max thread count. Finally, if
* all threads are in use, this method waits 2 seconds and tries again, up to ten times. After that, it returns a
* null.
+ *
+ * @return A connection from the pool.
*/
public Connection getConnection() {
@@ -362,6 +366,10 @@ public class SimplePool implements Runnable {
/**
* Returns the local JDBC ID for a connection.
+ *
+ * @param conn The connection object.
+ *
+ * @return The local JDBC ID for the connection.
*/
public int idOfConnection(Connection conn) {
int match = -1;
@@ -384,6 +392,10 @@ public class SimplePool implements Runnable {
/**
* Frees a connection. Replaces connection back into the main pool for reuse.
+ *
+ * @param conn The connection object.
+ *
+ * @return A status or empty string.
*/
public String freeConnection(Connection conn) {
String res = "";
@@ -403,6 +415,10 @@ public class SimplePool implements Runnable {
/**
* Returns the age of a connection -- the time since it was handed out to an application.
+ *
+ * @param conn The connection object.
+ *
+ * @return The age of the connection.
*/
public long getAge(Connection conn) { // Returns the age of the connection in millisec.
int thisconn = idOfConnection(conn);
@@ -536,6 +552,8 @@ public class SimplePool implements Runnable {
* This method could be reduced to return a counter that is maintained by all methods that update connStatus.
* However, it is more efficient to do it this way because: Updating the counter would put an additional burden on
* the most frequently used methods; in comparison, this method is rarely used (although essential).
+ *
+ * @return The number of connections in use.
*/
public int getUseCount() {
int useCount = 0;
@@ -551,6 +569,8 @@ public class SimplePool implements Runnable {
/**
* Returns the number of connections in the dynamic pool.
+ *
+ * @return The number of connections in the pool.
*/
public int getSize() {
return currConnections;
diff --git a/src/net/java/dev/simplepool/SimplePoolConnection.java b/src/net/java/dev/simplepool/SimplePoolConnection.java
index e5ba946..ac9633d 100644
--- a/src/net/java/dev/simplepool/SimplePoolConnection.java
+++ b/src/net/java/dev/simplepool/SimplePoolConnection.java
@@ -67,8 +67,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setAutoCommit(boolean)}.
- *
- * @see java.sql.Connection#setAutoCommit(boolean)
*/
public void setAutoCommit(boolean autoCommit)
throws SQLException {
@@ -77,8 +75,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getAutoCommit}.
- *
- * @see java.sql.Connection#getAutoCommit
*/
public boolean getAutoCommit()
throws SQLException {
@@ -87,8 +83,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setCatalog(String)}.
- *
- * @see java.sql.Connection#setCatalog(String)
*/
public void setCatalog(String catalog)
throws SQLException {
@@ -97,8 +91,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getCatalog()}.
- *
- * @see java.sql.Connection#getCatalog()
*/
public String getCatalog()
throws SQLException {
@@ -107,8 +99,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#isClosed}.
- *
- * @see java.sql.Connection#isClosed
*/
public boolean isClosed()
throws SQLException {
@@ -117,8 +107,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setHoldability(int)}.
- *
- * @see java.sql.Connection#setHoldability(int)
*/
public void setHoldability(int holdability)
throws SQLException {
@@ -127,8 +115,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getHoldability}.
- *
- * @see java.sql.Connection#getHoldability
*/
public int getHoldability()
throws SQLException {
@@ -137,8 +123,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getMetaData}.
- *
- * @see java.sql.Connection#getMetaData
*/
public DatabaseMetaData getMetaData()
throws SQLException {
@@ -147,8 +131,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setReadOnly(boolean)}.
- *
- * @see java.sql.Connection#setReadOnly(boolean)
*/
public void setReadOnly(boolean readOnly)
throws SQLException {
@@ -157,8 +139,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#isReadOnly}.
- *
- * @see java.sql.Connection#isReadOnly
*/
public boolean isReadOnly()
throws SQLException {
@@ -167,8 +147,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setSavepoint}.
- *
- * @see java.sql.Connection#setSavepoint
*/
public Savepoint setSavepoint()
throws SQLException {
@@ -177,8 +155,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setSavepoint(String)}.
- *
- * @see java.sql.Connection#setSavepoint(String)
*/
public Savepoint setSavepoint(String savepoint)
throws SQLException {
@@ -187,8 +163,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setTransactionIsolation(int)}.
- *
- * @see java.sql.Connection#setTransactionIsolation(int)
*/
public void setTransactionIsolation(int level)
throws SQLException {
@@ -197,8 +171,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getTransactionIsolation}.
- *
- * @see java.sql.Connection#getTransactionIsolation
*/
public int getTransactionIsolation()
throws SQLException {
@@ -207,8 +179,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#setTypeMap(Map)}.
- *
- * @see java.sql.Connection#setTypeMap(Map)
*/
public void setTypeMap(Map map)
throws SQLException {
@@ -217,8 +187,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getTypeMap}.
- *
- * @see java.sql.Connection#getTypeMap
*/
public Map getTypeMap()
throws SQLException {
@@ -227,8 +195,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#getWarnings}.
- *
- * @see java.sql.Connection#getWarnings
*/
public SQLWarning getWarnings()
throws SQLException {
@@ -237,8 +203,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#clearWarnings}.
- *
- * @see java.sql.Connection#clearWarnings
*/
public void clearWarnings()
throws SQLException {
@@ -247,8 +211,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#close}.
- *
- * @see java.sql.Connection#close
*/
public void close()
throws SQLException {
@@ -257,8 +219,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#commit}.
- *
- * @see java.sql.Connection#commit
*/
public void commit()
throws SQLException {
@@ -267,8 +227,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#createStatement}.
- *
- * @see java.sql.Connection#createStatement
*/
public Statement createStatement()
throws SQLException {
@@ -277,8 +235,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#createStatement(int, int)}.
- *
- * @see java.sql.Connection#createStatement(int, int)
*/
public Statement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException {
@@ -287,8 +243,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#createStatement(int, int, int)}.
- *
- * @see java.sql.Connection#createStatement(int, int, int)
*/
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
@@ -297,8 +251,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#nativeSQL(String)}.
- *
- * @see java.sql.Connection#nativeSQL(String)
*/
public String nativeSQL(String sql)
throws SQLException {
@@ -307,8 +259,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareCall(String)}.
- *
- * @see java.sql.Connection#prepareCall(String)
*/
public CallableStatement prepareCall(String sql)
throws SQLException {
@@ -317,8 +267,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareCall(String, int, int)}.
- *
- * @see java.sql.Connection#prepareCall(String, int, int)
*/
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
@@ -327,8 +275,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareCall(String, int, int, int)}.
- *
- * @see java.sql.Connection#prepareCall(String, int, int, int)
*/
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
@@ -337,8 +283,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String)}.
- *
- * @see java.sql.Connection#prepareStatement(String)
*/
public PreparedStatement prepareStatement(String sql)
throws SQLException {
@@ -347,8 +291,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String)}.
- *
- * @see java.sql.Connection#prepareStatement(String)
*/
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException {
@@ -357,8 +299,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String, int, int)}.
- *
- * @see java.sql.Connection#prepareStatement(String, int, int)
*/
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
@@ -367,8 +307,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String, int, int, int)}.
- *
- * @see java.sql.Connection#prepareStatement(String, int, int, int)
*/
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
@@ -377,8 +315,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String, int[])}.
- *
- * @see java.sql.Connection#prepareStatement(String, int[])
*/
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
throws SQLException {
@@ -387,8 +323,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#prepareStatement(String, String[])}.
- *
- * @see java.sql.Connection#prepareStatement(String, String[])
*/
public PreparedStatement prepareStatement(String sql, String[] columnNames)
throws SQLException {
@@ -397,8 +331,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#releaseSavepoint(Savepoint)}.
- *
- * @see java.sql.Connection#releaseSavepoint(Savepoint)
*/
public void releaseSavepoint(Savepoint savepoint)
throws SQLException {
@@ -407,8 +339,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#rollback}.
- *
- * @see java.sql.Connection#rollback
*/
public void rollback()
throws SQLException {
@@ -417,8 +347,6 @@ public class SimplePoolConnection implements Connection {
/**
* See {@link java.sql.Connection#rollback(Savepoint)}.
- *
- * @see java.sql.Connection#rollback(Savepoint)
*/
public void rollback(Savepoint savepoint)
throws SQLException {
diff --git a/src/net/java/dev/simplepool/SimplePoolDataSource.java b/src/net/java/dev/simplepool/SimplePoolDataSource.java
index 47b1362..e756646 100644
--- a/src/net/java/dev/simplepool/SimplePoolDataSource.java
+++ b/src/net/java/dev/simplepool/SimplePoolDataSource.java
@@ -80,8 +80,6 @@ public class SimplePoolDataSource implements DataSource {
/**
* See {@link javax.sql.DataSource#getConnection()}.
- *
- * @see javax.sql.DataSource#getConnection()
*/
public Connection getConnection() throws SQLException {
@@ -99,8 +97,6 @@ public class SimplePoolDataSource implements DataSource {
/**
* See {@link javax.sql.DataSource#getConnection(String, String)}.
- *
- * @see javax.sql.DataSource#getConnection(String, String)
*/
public Connection getConnection(String username, String password)
throws SQLException {
@@ -111,8 +107,6 @@ public class SimplePoolDataSource implements DataSource {
/**
* See {@link javax.sql.DataSource#setLogWriter(PrintWriter)}.
- *
- * @see javax.sql.DataSource#setLogWriter(PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws SQLException {
logWriter = out;
@@ -120,8 +114,6 @@ public class SimplePoolDataSource implements DataSource {
/**
* See {@link javax.sql.DataSource#getLogWriter}.
- *
- * @see javax.sql.DataSource#getLogWriter
*/
public PrintWriter getLogWriter() {
return logWriter;
@@ -129,16 +121,12 @@ public class SimplePoolDataSource implements DataSource {
/**
* See {@link javax.sql.DataSource#setLoginTimeout(int)}.
- *
- * @see javax.sql.DataSource#setLoginTimeout(int)
*/
public void setLoginTimeout(int seconds) throws SQLException {
}
/**
* See {@link javax.sql.DataSource#getLoginTimeout}.
- *
- * @see javax.sql.DataSource#getLoginTimeout
*/
public int getLoginTimeout() {
return 0;
@@ -154,13 +142,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the JDBC driver.
+ *
+ * @param driver The JDBC driver. e.g. 'com.mysql.jdbc.Driver'
+ *
+ * @see #getDriver()
*/
- public void setDriver(String val) {
- driver = val;
+ public void setDriver(String driver) {
+ this.driver = driver;
}
/**
* Gets the JDBC driver.
+ *
+ * @return The JDBC driver string.
+ *
+ * @see #setDriver(String)
*/
public String getDriver() {
return driver;
@@ -168,13 +164,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the JDBC connect string.
+ *
+ * @param jdbcUrl The JDBC connection URL string. e.g. 'jdbc:mysql://localhost:3306/dbname'
+ *
+ * @see #getJdbcUrl()
*/
- public void setJdbcUrl(String val) {
- jdbcUrl = val;
+ public void setJdbcUrl(String jdbcUrl) {
+ this.jdbcUrl = jdbcUrl;
}
/**
- * Sets the JDBC connect string.
+ * Gets the JDBC connect string.
+ *
+ * @return The JDBC connection URL string.
+ *
+ * @see #setJdbcUrl(String)
*/
public String getJdbcUrl() {
return jdbcUrl;
@@ -182,13 +186,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the database login name.
+ *
+ * @param user The database login name. e.g. 'Scott'
+ *
+ * @see #getUser()
*/
- public void setUser(String val) {
- user = val;
+ public void setUser(String user) {
+ this.user = user;
}
/**
* Gets the database login name.
+ *
+ * @return The login name string.
+ *
+ * @see #setUser(String)
*/
public String getUser() {
return user;
@@ -196,13 +208,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the database password.
+ *
+ * @param password The database password. e.g. 'Tiger'
+ *
+ * @see #getPassword()
*/
- public void setPassword(String val) {
- password = val;
+ public void setPassword(String password) {
+ this.password = password;
}
/**
* Gets the database password.
+ *
+ * @return The password string.
+ *
+ * @see #setPassword(String)
*/
public String getPassword() {
return password;
@@ -210,13 +230,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the minimum number of connections to start with.
+ *
+ * @param minConns The minimum number of connections.
+ *
+ * @see #getMinConns()
*/
- public void setMinConns(String val) {
- minConns = val;
+ public void setMinConns(String minConns) {
+ this.minConns = minConns;
}
/**
* Gets the minimum number of connections to start with.
+ *
+ * @return The minimum number of connections string.
+ *
+ * @see #setMinConns(String)
*/
public String getMinConns() {
return minConns;
@@ -224,13 +252,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the maximum number of connections in dynamic pool.
+ *
+ * @param maxConns The maximum number of connections.
+ *
+ * @see #getMaxConns()
*/
- public void setMaxConns(String val) {
- maxConns = val;
+ public void setMaxConns(String maxConns) {
+ this.maxConns = maxConns;
}
/**
* Gets the maximum number of connections in dynamic pool.
+ *
+ * @return The maximum number of connection string.
+ *
+ * @see #setMaxConns(String)
*/
public String getMaxConns() {
return maxConns;
@@ -238,13 +274,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the time in days between connection resets.
+ *
+ * @param maxConnTime The maximum connection time.
+ *
+ * @see #getMaxConnTime()
*/
- public void setMaxConnTime(String val) {
- maxConnTime = val;
+ public void setMaxConnTime(String maxConnTime) {
+ this.maxConnTime = maxConnTime;
}
/**
* Gets the time in days between connection resets.
+ *
+ * @return The maximum connection time string.
+ *
+ * @see #setMaxConnTime(String)
*/
public String getMaxConnTime() {
return maxConnTime;
@@ -252,13 +296,21 @@ public class SimplePoolDataSource implements DataSource {
/**
* Sets the max time a connection can be checked out before being recycled.
+ *
+ * @param maxCheckoutSeconds The maximum number of seconds to wait before recycling a connection.
+ *
+ * @see #getMaxCheckoutSeconds()
*/
- public void setMaxCheckoutSeconds(String val) {
- maxCheckoutSeconds = val;
+ public void setMaxCheckoutSeconds(String maxCheckoutSeconds) {
+ this.maxCheckoutSeconds = maxCheckoutSeconds;
}
/**
- * Sets the max time a connection can be checked out before being recycled.
+ * Gets the max time a connection can be checked out before being recycled.
+ *
+ * @return The maximum checkout time string.
+ *
+ * @see #setMaxCheckoutSeconds(String)
*/
public String getMaxCheckoutSeconds() {
return maxCheckoutSeconds;
diff --git a/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java b/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java
index f73babc..ce845f3 100644
--- a/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java
+++ b/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java
@@ -77,8 +77,8 @@ public class SimplePoolDataSourceFactory implements ObjectFactory {
/*
driver: JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'
jdbcUrl: JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'
- user: Database login name. e.g. 'Scott'
- password: Database password. e.g. 'Tiger'
+ user: Database login name. e.g. 'Scott'
+ password: Database password. e.g. 'Tiger'
minConns: Minimum number of connections to start with.
maxConns: Maximum number of connections in dynamic pool.
maxConnTime: Time in days between connection resets. (Reset does a basic cleanup)
diff --git a/src/net/java/dev/simplepool/SimplePoolServlet.java b/src/net/java/dev/simplepool/SimplePoolServlet.java
index 1ba9c43..bf64a9e 100644
--- a/src/net/java/dev/simplepool/SimplePoolServlet.java
+++ b/src/net/java/dev/simplepool/SimplePoolServlet.java
@@ -72,6 +72,20 @@ public class SimplePoolServlet extends HttpServlet {
/**
* Initializes the connection pool.
+ *
varName
– Name of the variable used to hold a reference to the {@link SimplePoolDataSource}.driver
– JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'jdbcUrl
– JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'user
– Database login name. e.g. 'Scott'password
– Database password. e.g. 'Tiger'minConns
– Minimum number of connections to start with.maxConns
– Maximum number of connections in dynamic pool.maxConnTime
– Time in days between connection resets.maxCheckoutSeconds
– Max time a connection can be checked out before being recycled.