com.jolbox.bonecp
Class BoneCPDataSource

java.lang.Object
  extended by com.jolbox.bonecp.BoneCPConfig
      extended by com.jolbox.bonecp.BoneCPDataSource
All Implemented Interfaces:
BoneCPConfigMBean, java.io.Serializable, java.lang.Cloneable, java.sql.Wrapper, javax.naming.spi.ObjectFactory, javax.sql.CommonDataSource, javax.sql.DataSource

public class BoneCPDataSource
extends BoneCPConfig
implements javax.sql.DataSource, javax.naming.spi.ObjectFactory

DataSource for use with LazyConnection Provider etc.

Author:
wallacew
See Also:
Serialized Form

Constructor Summary
BoneCPDataSource()
          Default empty constructor.
BoneCPDataSource(BoneCPConfig config)
           
 
Method Summary
 void close()
          Close the datasource.
 boolean equals(java.lang.Object obj)
           
 BoneCPConfig getConfig()
          Returns a configuration object built during initialization of the connection pool.
 java.sql.Connection getConnection()
          
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
          
 java.lang.String getDriverClass()
          Gets driver class set in config.
 int getLoginTimeout()
          Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 java.io.PrintWriter getLogWriter()
          Retrieves the log writer for this DataSource object.
 java.lang.Object getObjectInstance(java.lang.Object object, javax.naming.Name name, javax.naming.Context context, java.util.Hashtable<?,?> table)
           
 int getTotalLeased()
          Returns the total leased connections.
 int hashCode()
           
 boolean isWrapperFor(java.lang.Class<?> arg0)
          Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.
 void setDriverClass(java.lang.String driverClass)
          Sets driver to use (called via reflection).
 void setLoginTimeout(int seconds)
          Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.
 void setLogWriter(java.io.PrintWriter out)
          Sets the log writer for this DataSource object to the given java.io.PrintWriter object.
 java.lang.Object unwrap(java.lang.Class arg0)
          Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
 
Methods inherited from class com.jolbox.bonecp.BoneCPConfig
clone, getAcquireIncrement, getAcquireRetryAttempts, getAcquireRetryDelay, getAcquireRetryDelay, getAcquireRetryDelayInMs, getClassLoader, getCloseConnectionWatchTimeout, getCloseConnectionWatchTimeout, getCloseConnectionWatchTimeoutInMs, getConfigFile, getConnectionHook, getConnectionHookClassName, getConnectionTestStatement, getConnectionTimeout, getConnectionTimeout, getConnectionTimeoutInMs, getDatasourceBean, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDriverProperties, getIdleConnectionTestPeriod, getIdleConnectionTestPeriod, getIdleConnectionTestPeriodInMinutes, getIdleMaxAge, getIdleMaxAge, getIdleMaxAgeInMinutes, getInitSQL, getJdbcUrl, getMaxConnectionAge, getMaxConnectionAge, getMaxConnectionAgeInSeconds, getMaxConnectionsPerPartition, getMinConnectionsPerPartition, getPartitionCount, getPassword, getPoolAvailabilityThreshold, getPoolName, getPreparedStatementCacheSize, getPreparedStatementsCacheSize, getQueryExecuteTimeLimit, getQueryExecuteTimeLimit, getQueryExecuteTimeLimitInMs, getReleaseHelperThreads, getServiceOrder, getStatementCacheSize, getStatementReleaseHelperThreads, getStatementsCachedPerConnection, getStatementsCacheSize, getUsername, isCloseConnectionWatch, isDisableConnectionTracking, isDisableJMX, isLazyInit, isLogStatementsEnabled, isStatisticsEnabled, isTransactionRecoveryEnabled, sanitize, setAcquireIncrement, setAcquireRetryAttempts, setAcquireRetryDelay, setAcquireRetryDelay, setAcquireRetryDelayInMs, setClassLoader, setCloseConnectionWatch, setCloseConnectionWatchTimeout, setCloseConnectionWatchTimeout, setCloseConnectionWatchTimeoutInMs, setConfigFile, setConnectionHook, setConnectionHookClassName, setConnectionTestStatement, setConnectionTimeout, setConnectionTimeout, setConnectionTimeoutInMs, setDatasourceBean, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDisableConnectionTracking, setDisableJMX, setDriverProperties, setIdleConnectionTestPeriod, setIdleConnectionTestPeriod, setIdleConnectionTestPeriodInMinutes, setIdleConnectionTestPeriodInSeconds, setIdleMaxAge, setIdleMaxAge, setIdleMaxAgeInMinutes, setIdleMaxAgeInSeconds, setInitSQL, setJdbcUrl, setLazyInit, setLogStatementsEnabled, setMaxConnectionAge, setMaxConnectionAge, setMaxConnectionAgeInSeconds, setMaxConnectionsPerPartition, setMinConnectionsPerPartition, setPartitionCount, setPassword, setPoolAvailabilityThreshold, setPoolName, setPreparedStatementsCacheSize, setProperties, setQueryExecuteTimeLimit, setQueryExecuteTimeLimit, setQueryExecuteTimeLimitInMs, setReleaseHelperThreads, setServiceOrder, setStatementCacheSize, setStatementReleaseHelperThreads, setStatementsCachedPerConnection, setStatementsCacheSize, setStatisticsEnabled, setTransactionRecoveryEnabled, setUsername, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoneCPDataSource

public BoneCPDataSource()
Default empty constructor.


BoneCPDataSource

public BoneCPDataSource(BoneCPConfig config)
Parameters:
config -
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getConnection()

close

public void close()
Close the datasource.


getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getConnection(java.lang.String, java.lang.String)

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Retrieves the log writer for this DataSource object.

Specified by:
getLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise, it means that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException
Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

Specified by:
setLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> arg0)
                     throws java.sql.SQLException
Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.

Specified by:
isWrapperFor in interface java.sql.Wrapper
Parameters:
arg0 - class
Returns:
t/f
Throws:
java.sql.SQLException - on error

unwrap

public java.lang.Object unwrap(java.lang.Class arg0)
                        throws java.sql.SQLException
Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

Specified by:
unwrap in interface java.sql.Wrapper
Parameters:
arg0 - obj
Returns:
unwrapped object
Throws:
java.sql.SQLException

getDriverClass

public java.lang.String getDriverClass()
Gets driver class set in config.

Returns:
Driver class set in config

setDriverClass

public void setDriverClass(java.lang.String driverClass)
Sets driver to use (called via reflection).

Parameters:
driverClass - Driver to use

getTotalLeased

public int getTotalLeased()
Returns the total leased connections.

Returns:
total leased connections

getConfig

public BoneCPConfig getConfig()
Returns a configuration object built during initialization of the connection pool.

Returns:
the config

getObjectInstance

public java.lang.Object getObjectInstance(java.lang.Object object,
                                          javax.naming.Name name,
                                          javax.naming.Context context,
                                          java.util.Hashtable<?,?> table)
                                   throws java.lang.Exception
Specified by:
getObjectInstance in interface javax.naming.spi.ObjectFactory
Throws:
java.lang.Exception

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class BoneCPConfig

hashCode

public int hashCode()
Overrides:
hashCode in class BoneCPConfig


Copyright © 2009-2011 JolBox. All Rights Reserved.