* until a connection has become available.
* If a connection is not retrieved, the Future must be cancelled in order for the connection to be returned
* to the pool.
- * @return
+ * @return a Future containing a reference to the connection or the future connection
* @throws SQLException
*/
public Future<Connection> getConnectionAsync() throws SQLException {
* All calls on {@link java.sql.Connection} methods will be propagated down to the actual JDBC connection except for the
* {@link java.sql.Connection#close()} method.
* @param con a {@link PooledConnection} to wrap in a Proxy
- * @return a {@java.sql.Connection} object wrapping a pooled connection.
+ * @return a {@link java.sql.Connection} object wrapping a pooled connection.
* @throws SQLException if an interceptor can't be configured, if the proxy can't be instantiated
*/
protected Connection setupConnection(PooledConnection con) throws SQLException {
*/
package org.apache.tomcat.jdbc.pool;
+import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import java.sql.SQLException;
import java.util.Hashtable;
}
/**
- * Registers the ConnectionPoolMBean
+ * Registers the ConnectionPoolMBean under a unique name based on the ObjectName for the DataSource
*/
protected void registerJmx() {
try {
//===============================================================================
// Expose JMX attributes through Tomcat's dynamic reflection
//===============================================================================
+ /**
+ * Forces an abandon check on the connection pool.
+ * If connections that have been abandoned exists, they will be closed during this run
+ */
public void checkAbandoned() {
try {
createPool().checkAbandoned();
}
}
+ /**
+ * Forces a check for downsizing the idle connections
+ */
public void checkIdle() {
try {
createPool().checkIdle();
}
}
+ /**
+ * @return number of connections in use by the application
+ */
public int getActive() {
try {
return createPool().getActive();
}
}
+ /**
+ * @return number of connections in use by the application
+ * {@link DataSource#getActive()}
+ */
public int getNumActive() {
return getActive();
}
+ /**
+ * @return number of threads waiting for a connection
+ */
public int getWaitCount() {
try {
return createPool().getWaitCount();
}
}
+ /**
+ * NOT USED ANYWHERE
+ * @return nothing
+ */
public String getConnectionProperties() {
try {
return createPool().getPoolProperties().getConnectionProperties();
}
}
+ /**
+ * @return connection properties passed into the JDBC Driver upon connect
+ */
public Properties getDbProperties() {
try {
return createPool().getPoolProperties().getDbProperties();
}
}
+ /**
+ * @return the configured default catalog
+ */
public String getDefaultCatalog() {
try {
return createPool().getPoolProperties().getDefaultCatalog();
}
}
+ /**
+ * @return the configured default isolation level
+ */
public int getDefaultTransactionIsolation() {
try {
return createPool().getPoolProperties().getDefaultTransactionIsolation();
}
}
+ /**
+ * @return the configured driver class name
+ */
public String getDriverClassName() {
try {
return createPool().getPoolProperties().getDriverClassName();
}
}
+ /**
+ * @return the number of established but idle connections
+ */
public int getIdle() {
try {
return createPool().getIdle();
throw new RuntimeException(x);
}
}
-
+
+ /**
+ * {@link #getIdle()}
+ */
public int getNumIdle() {
return getIdle();
}
+ /**
+ * @return the configured number of initial connections
+ */
public int getInitialSize() {
try {
return createPool().getPoolProperties().getInitialSize();
}
}
+ /**
+ * @return the configured initialization SQL
+ */
public String getInitSQL() {
try {
return createPool().getPoolProperties().getInitSQL();
}
}
+ /**
+ * @return the configuration string for interceptors
+ */
public String getJdbcInterceptors() {
try {
return createPool().getPoolProperties().getJdbcInterceptors();
}
}
+ /**
+ * @return the configured number of maximum allowed connections
+ */
public int getMaxActive() {
try {
return createPool().getPoolProperties().getMaxActive();
}
}
+ /**
+ * @return the configured number of maximum idle connections
+ */
public int getMaxIdle() {
try {
return createPool().getPoolProperties().getMaxIdle();
}
}
+ /**
+ * @return the configured maximum wait time in milliseconds if a connection is not available
+ */
public int getMaxWait() {
try {
return createPool().getPoolProperties().getMaxWait();
}
}
+ /**
+ * @return the configured idle time, before a connection that is idle can be released
+ */
public int getMinEvictableIdleTimeMillis() {
try {
return createPool().getPoolProperties().getMinEvictableIdleTimeMillis();
}
}
+ /**
+ * @return the configured minimum amount of idle connections
+ */
public int getMinIdle() {
try {
return createPool().getPoolProperties().getMinIdle();
}
}
+ /**
+ * @return the configured maxAge for a connection.
+ * A connection that has been established for longer than this configured value in milliseconds
+ * will be closed upon a return
+ */
public long getMaxAge() {
try {
return createPool().getPoolProperties().getMaxAge();
}
}
+ /**
+ * @return the name of the pool
+ */
public String getName() {
try {
return createPool().getName();
}
}
+ /**
+ * @return the configured value - not used in this implementation
+ */
public int getNumTestsPerEvictionRun() {
try {
return createPool().getPoolProperties().getNumTestsPerEvictionRun();
}
}
+ /**
+ * @return DOES NOT RETURN THE PASSWORD, IT WOULD SHOW UP IN JMX
+ */
public String getPassword() {
return "Password not available as DataSource/JMX operation.";
}
+ /**
+ * @return the configured remove abandoned timeout in seconds
+ */
public int getRemoveAbandonedTimeout() {
try {
return createPool().getPoolProperties().getRemoveAbandonedTimeout();
}
}
+ /**
+ * @return the current size of the pool
+ */
public int getSize() {
try {
return createPool().getSize();
throw new RuntimeException(x);
}
}
-
}
}
/**
- * Creates and configures a {@link BasicDataSource} instance based on the
+ * Creates and configures a {@link DataSource} instance based on the
* given properties.
*
* @param properties the datasource configuration properties
}
/**
- * {@inheritDoc}
+ * {@link javax.sql.DataSource#getConnection()}
*/
public Connection getConnection(String username, String password) throws SQLException {
return getConnection();
}
/**
- * {@inheritDoc}
+ * {@link javax.sql.DataSource#getConnection()}
*/
public Connection getConnection() throws SQLException {
/**
* Invokes an sync operation to retrieve the connection.
- * @return
+ * @return a Future containing a reference to the connection when it becomes available
* @throws SQLException
*/
public Future<Connection> getConnectionAsync() throws SQLException {
}
/**
- * {@inheritDoc}
+ * {@link javax.sql.DataSource#getConnection()}
*/
public PooledConnection getPooledConnection() throws SQLException {
return (PooledConnection) getConnection();
}
/**
- * {@inheritDoc}
+ * {@link javax.sql.DataSource#getConnection()}
*/
public PooledConnection getPooledConnection(String username,
String password) throws SQLException {
return pool.getName();
}
- /**
- * {@inheritDoc}
- */
- public PrintWriter getLogWriter() throws SQLException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLogWriter(PrintWriter out) throws SQLException {
- }
-
- /**
- * {@inheritDoc}
- */
- public int getLoginTimeout() {
- if (poolProperties == null) {
- return 0;
- } else {
- return poolProperties.getMaxWait() / 1000;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void setLoginTimeout(int i) {
- if (poolProperties == null) {
- return;
- } else {
- poolProperties.setMaxWait(1000 * i);
- }
-
- }
+
public void close() {
this.getPoolProperties().setUseEquals(useEquals);
}
+ /**
+ * no-op
+ * {@link javax.sql.DataSource#getLogWriter}
+ */
+ public PrintWriter getLogWriter() throws SQLException {
+ return null;
+ }
+
+ /**
+ * {@link javax.sql.DataSource#setLogWriter(PrintWriter)}
+ */
+ public void setLogWriter(PrintWriter out) throws SQLException {
+ }
+
+ /**
+ * {@link javax.sql.DataSource#getLoginTimeout}
+ */
+ public int getLoginTimeout() {
+ if (poolProperties == null) {
+ return 0;
+ } else {
+ return poolProperties.getMaxWait() / 1000;
+ }
+ }
+
+ /**
+ * {@link javax.sql.DataSource#setLoginTimeout(int)}
+ */
+ public void setLoginTimeout(int i) {
+ if (poolProperties == null) {
+ return;
+ } else {
+ poolProperties.setMaxWait(1000 * i);
+ }
+
+ }
+
+
+
}
/**
* Returns the next interceptor in the chain
- * @return
+ * @return the next interceptor in the chain
*/
public JdbcInterceptor getNext() {
return next;
* Performs a string comparison, using references unless the useEquals property is set to true.
* @param name1
* @param name2
- * @return
+ * @return true if name1 is equal to name2 based on {@link #useEquals}
*/
public boolean compare(String name1, String name2) {
if (isUseEquals()) {
/**
* Compares a method name (String) to a method (Method)
- * {@link compare(String,String)}
+ * {@link #compare(String,String)}
* Uses reference comparison unless the useEquals property is set to true
* @param methodName
* @param method
}
/**
- * Set to true if string comparisons (for the {@link compare} method) should use the Object.equals(Object) method
+ * Set to true if string comparisons (for the {@link #compare(String, Method)} and {@link #compare(String, String)} methods) should use the Object.equals(Object) method
* The default is false
* @param useEquals
*/
/**
* Returns the underlying connection
- * @return
+ * @return the underlying JDBC connection as it was returned from the JDBC driver
*/
public java.sql.Connection getConnection() {
return this.connection;
/**
* Returns the first handler in the interceptor chain
- * @return
+ * @return the first interceptor for this connection
*/
public JdbcInterceptor getHandler() {
return (handler!=null)?handler.get():null;
/**
* This method should return a wrapper object around a
- * java.sql.Statement, java.sql.PreparedStatement or java.sql.CallableStatement
+ * {@link java.sql.Statement}, {@link java.sql.PreparedStatement} or {@link java.sql.CallableStatement}
* @param proxy
* @param method
* @param args
* @param statement
- * @return
+ * @return a {@link java.sql.Statement} object
*/
public abstract Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time);
/**
* Invoked when prepareCall has been called and completed.
- * @param sql - the string used to prepare the statement with
+ * @param query - the string used to prepare the statement with
* @param time - the time it took to invoke prepare
*/
protected abstract void prepareCall(String query, long time);
* @param args
* @param name
* @param start
- * @param t
+ * @param delta
* @return - the SQL that was executed or the string "batch"
*/
protected String reportQuery(String query, Object[] args, final String name, long start, long delta) {
* @param args
* @param name
* @param start
- * @param t
+ * @param delta
* @return - the SQL that was executed or the string "batch"
*/
protected String reportSlowQuery(String query, Object[] args, final String name, long start, long delta) {
/**
* returns the query measure threshold.
* This value is in milliseconds. If the query is faster than this threshold than it wont be accounted for
- * @return
+ * @return the threshhold in milliseconds
*/
public long getThreshold() {
return threshold;
/**
* Returns the query stats for a given pool
- * @param pool - the pool we want to retrieve stats for
+ * @param poolname - the name of the pool we want to retrieve stats for
* @return a hash map containing statistics for 0 to maxQueries
*/
public static ConcurrentHashMap<String,QueryStats> getPoolStats(String poolname) {
/**
* JMX operation - return the names of all the pools
- * @return
+ * @return - all the names of pools that we have stored data for
*/
public String[] getPoolNames() {
Set<String> keys = perPoolStats.keySet();
/**
* JMX operation - return the name of the pool
- * @return
+ * @return the name of the pool, unique within the JVM
*/
public String getPoolName() {
return poolName;
/**
* JMX operation - returns all the queries we have collected.
- * @return
+ * @return - the slow query report as composite data.
*/
public CompositeData[] getSlowQueriesCD() throws OpenDataException {
CompositeDataSupport[] result = null;
* Return true if the notification was sent successfully, false otherwise.
* @param type
* @param message
- * @return
+ * @return true if the notification succeeded
*/
public boolean notify(final String type, String message) {
try {