Package com.nuodb.jdbc
Class DataSource
- java.lang.Object
-
- com.nuodb.jdbc.DataSource
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Wrapper,CommonDataSource,ConnectionPoolDataSource,DataSource
- Direct Known Subclasses:
NuoXADataSource
public class DataSource extends Object implements DataSource, ConnectionPoolDataSource, Closeable
-
-
Field Summary
Fields Modifier and Type Field Description static String[]ALL_PROPERTIESArray of all properties recognized and accepted by this datasource.static longDEFAULT_INITIALSIZE(long) Sets default for initial number of connections established during datasource initialization to 10.static intDEFAULT_MAXSTATEMENTS(int) Sets default for the global maximum limit of statements per datasource to 0, which means no limit will be enforced.static intDEFAULT_MAXSTATEMENTSPERCONNECTION(int) Sets default for per-connection maximum of prepared and callable statements to 0.static StringDEFAULT_URL(String) The connection url jdbc:com.nuodb://localhost:48004static StringDRIVER_CLASS_NAMEstatic StringDRIVER_URL_PREFIXstatic StringHIBERNATE_DRIVER_CLASS_NAMEstatic StringHIBERNATE_DRIVER_URL_PREFIXstatic StringPROP_DEFAULTAUTOCOMMIT(boolean) The default auto-commit state of connections created by this pool.static StringPROP_DEFAULTREADONLY(boolean) The default read-only state of connections created by this pool.static StringPROP_IDLEVALIDATIONINTERVAL(int) The number of milliseconds to sleep between runs of the idle connection validation/cleaner thread.static StringPROP_INITIALSIZE(int) The initial number of connections that are created when the pool is started.static StringPROP_MAXACTIVE(int) The maximum number of active connections that can be allocated from this pool at the same time.static StringPROP_MAXAGE(long) Time in milliseconds to keep this connection.static StringPROP_MAXIDLE(int) The maximum number of connections that should be kept in the pool at all times.static StringPROP_MAXSTATEMENTS(int) The size of global statement cache, if 0 there is not limit.static StringPROP_MAXSTATEMENTSPERCONNECTION(int) The number of statements cached for a single pooled connection.static StringPROP_MAXWAIT(int) The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.static StringPROP_MINIDLE(int) The minimum number of established connections that should be kept in the pool at all times.static StringPROP_PASSWORD(String) The connection password to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.static StringPROP_SCHEMA(String) The default schema of connections created by this pool.static StringPROP_SQL_ENGINE(String) The SQL engine used in the connections created by this pool.static StringPROP_TESTONBORROW(boolean) The indication of whether objects will be validated before being borrowed from the pool.static StringPROP_TESTONRETURN(boolean) The indication of whether objects will be validated before being returned to the pool.static StringPROP_TESTWHILEIDLE(boolean) The indication of whether objects will be validated by the idle object evictor.static StringPROP_URLThe URL of the NuoDB broker, optionally containing multiple brokers jdbc:com.nuodb://{broker}:{port}, {broker}:{port}, .../{database}, that will be contacted in case the primary one is unreachablestatic StringPROP_URLDELIMITER(String) The delimiter used to separate the URLs of the brokers in the value of the url property.static StringPROP_USER(String) The connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.static StringPROP_USERNAME(String) The connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.static StringPROP_VALIDATIONINTERVAL(long) To avoid excess validation, only run validation at most at this frequency - time in milliseconds.static StringPROP_VALIDATIONQUERY(String) The SQL query that will be used to validate connections from this pool before returning them to the caller.
-
Constructor Summary
Constructors Constructor Description DataSource()Creates a new data source, initialized from the default properties The connection and statement pool are configured but the initial connections are started when getConnection() is called.DataSource(Properties info)Creates a new data source, initialized from the provided properties And starts a connection and statement pool.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static booleanconnectionsAreIdentical(Connection lhs, Connection rhs)Checks whether two connection proxies point to the same connection in the poolcom.nuodb.jdbc.DataSource.ConnectionHelpercreateConnectionHelper(com.nuodb.jdbc.ConnectionKey connectionKey)ConnectiongetConnection()Returns connection proxy using the default user and password specified in the initialization properties.ConnectiongetConnection(String user, String password)Returns connection proxy created using provided user and password.intgetLoginTimeout()Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.PrintWritergetLogWriter()Retrieves the log writer for thisDataSourceobject used by theStandardLogger.LoggergetParentLogger()Gets the parent logger of all the loggers used by this data source.longgetPoolActiveConnectionSize()Get the number of active connections in the poolPooledConnectiongetPooledConnection()Establishes a physical database connection that can be used as a pooled connection using the default user and password specified in the initialization properties.PooledConnectiongetPooledConnection(String user, String password)Establishes a physical database connection that can be used as a pooled connection.longgetPoolIdleConnectionSize()Get the number of idle connections in the poolbooleanisWrapperFor(Class<?> type)voidsetDefaultAutoCommit(Boolean defaultAutoCommit)Sets the default auto-commit state of connections created by this pool.voidsetDefaultReadOnly(Boolean defaultReadOnly)Sets the default read-only state of connections created by this pool.voidsetDefaultSchema(String schema)Sets the default schema of connections created by this pool.voidsetInitialSize(long initialSize)Sets the initial number of connections that are created when the pool is started.voidsetLoginTimeout(int loginTimeout)Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.voidsetLogWriter(PrintWriter logWriter)Sets the log writer of the standard logger forDataSourceobject to the givenjava.io.PrintWriterobject.voidsetMaxActive(long maxActive)Sets the maximum number of active connections that can be allocated from this pool at the same time.voidsetMaxAge(long maxAge)Sets the time in milliseconds to keep this connection.voidsetMaxIdle(long maxIdle)Sets the maximum number of connections that should be kept in the pool at all times.voidsetMaxStatementsPerConnection(long maxStatementsPerConnection)Sets the number of statements cached for a single pooled connection.voidsetMaxWait(long maxWait)Sets the maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.voidsetMinIdle(long minIdle)Sets the minimum number of established connections that should be kept in the pool at all times.voidsetPassword(String password)Sets the connection password to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.voidsetProperties(Properties info)voidsetSchema(String schema)Sets the default schema of connections created by this pool.voidsetSQLEngine(String engine)Sets the SQL engine of connections created by this pool.voidsetTestOnBorrow(boolean testOnBorrow)Sets the indication of whether objects will be validated before being borrowed from the pool.voidsetTestOnReturn(boolean testOnReturn)Sets the indication of whether objects will be validated before being returned to the pool.voidsetTestWhileIdle(boolean testWhileIdle)Sets the indication of whether objects will be validated by the idle object evictor.voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)Sets the number of milliseconds to sleep between runs of the idle connection validation/cleaner thread.voidsetUrl(String url)Sets the URL of the NuoDB broker, optionally containing multiple brokers jdbc:com.nuodb://{broker}:{port}, {broker}:{port}, .../{database}, that will be contacted in case the primary one is unreachable This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)voidsetUrlDelimiter(String urlDelimiter)Sets the delimiter used to separate the URLs of the brokers in the value of the url property.voidsetUser(String user)Sets the connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.voidsetUsername(String username)Sets the username to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.voidsetValidationInterval(long validationInterval)Sets the validation interval.voidsetValidationQuery(String validationQuery)Sets the SQL query that will be used to validate connections from this pool before returning them to the caller.StringtoString()Returns the current configuration (except password) of the data source as a string.<T> Tunwrap(Class<T> type)-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
-
Methods inherited from interface javax.sql.ConnectionPoolDataSource
createPooledConnectionBuilder
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
-
-
-
Field Detail
-
PROP_URL
public static final String PROP_URL
The URL of the NuoDB broker, optionally containing multiple brokers jdbc:com.nuodb://{broker}:{port}, {broker}:{port}, .../{database}, that will be contacted in case the primary one is unreachable- See Also:
- Constant Field Values
-
PROP_USERNAME
public static final String PROP_USERNAME
(String) The connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.- See Also:
- Constant Field Values
-
PROP_USER
public static final String PROP_USER
(String) The connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.- See Also:
- Constant Field Values
-
PROP_PASSWORD
public static final String PROP_PASSWORD
(String) The connection password to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used.- See Also:
- Constant Field Values
-
PROP_SCHEMA
public static final String PROP_SCHEMA
(String) The default schema of connections created by this pool.- See Also:
- Constant Field Values
-
PROP_SQL_ENGINE
public static final String PROP_SQL_ENGINE
(String) The SQL engine used in the connections created by this pool.- See Also:
- Constant Field Values
-
PROP_MAXACTIVE
public static final String PROP_MAXACTIVE
(int) The maximum number of active connections that can be allocated from this pool at the same time. The default value is 100; if set to 0, there is no limit- See Also:
- Constant Field Values
-
PROP_MAXIDLE
public static final String PROP_MAXIDLE
(int) The maximum number of connections that should be kept in the pool at all times. Default value is the minimum between PROP_MAXACTIVE and 100.- See Also:
- Constant Field Values
-
PROP_MINIDLE
public static final String PROP_MINIDLE
(int) The minimum number of established connections that should be kept in the pool at all times. Default value is the minimum between from PROP_INITIALSIZE and 10- See Also:
- Constant Field Values
-
PROP_INITIALSIZE
public static final String PROP_INITIALSIZE
(int) The initial number of connections that are created when the pool is started. Default value is 10- See Also:
- Constant Field Values
-
PROP_MAXWAIT
public static final String PROP_MAXWAIT
(int) The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. Default value is 30000 (30 seconds)- See Also:
- Constant Field Values
-
PROP_MAXAGE
public static final String PROP_MAXAGE
(long) Time in milliseconds to keep this connection. When a connection is returned to the pool, the pool will check to see if the now - time-when-connected has reached PROP_MAXAGE, and if so, it closes the connection rather than returning it to the pool. The default value is 300000 (5 minutes). Setting it to 0 means that connections will be left open and no age check will be done.- See Also:
- Constant Field Values
-
PROP_DEFAULTREADONLY
public static final String PROP_DEFAULTREADONLY
(boolean) The default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called.- See Also:
- Constant Field Values
-
PROP_DEFAULTAUTOCOMMIT
public static final String PROP_DEFAULTAUTOCOMMIT
(boolean) The default auto-commit state of connections created by this pool. If not set, default is JDBC driver default (If not set then the setAutoCommit method will not be called.)- See Also:
- Constant Field Values
-
PROP_TESTONRETURN
public static final String PROP_TESTONRETURN
(boolean) The indication of whether objects will be validated before being returned to the pool. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. The default value is false.- See Also:
- Constant Field Values
-
PROP_TESTONBORROW
public static final String PROP_TESTONBORROW
(boolean) The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. Default value is false. In order to have a more efficient validation, see PROP_VALIDATIONINTERVAL- See Also:
- Constant Field Values
-
PROP_TESTWHILEIDLE
public static final String PROP_TESTWHILEIDLE
(boolean) The indication of whether objects will be validated by the idle object evictor. If an object fails to validate, it will be dropped from the pool. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. The default value is false.In order to have a more efficient validation, see PROP_VALIDATIONINTERVAL- See Also:
- Constant Field Values
-
PROP_VALIDATIONQUERY
public static final String PROP_VALIDATIONQUERY
(String) The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query does not have to return any data, it just can't throw a SQLException. The default value is null. Example value is SELECT 1 FROM DUAL- See Also:
- Constant Field Values
-
PROP_VALIDATIONINTERVAL
public static final String PROP_VALIDATIONINTERVAL
(long) To avoid excess validation, only run validation at most at this frequency - time in milliseconds. If a connection is due for validation, but has been validated previously within this interval, it will not be validated again. The default value is 30000 (30 seconds).- See Also:
- Constant Field Values
-
PROP_IDLEVALIDATIONINTERVAL
public static final String PROP_IDLEVALIDATIONINTERVAL
(int) The number of milliseconds to sleep between runs of the idle connection validation/cleaner thread. This value should not be set under 1 second. It dictates how often we check for idle, abandoned connections, and how often we validate idle connections. The default value is 5000 (5 seconds).- See Also:
- Constant Field Values
-
PROP_MAXSTATEMENTS
public static final String PROP_MAXSTATEMENTS
(int) The size of global statement cache, if 0 there is not limit.- See Also:
- Constant Field Values
-
PROP_MAXSTATEMENTSPERCONNECTION
public static final String PROP_MAXSTATEMENTSPERCONNECTION
(int) The number of statements cached for a single pooled connection. If the property is non-zero, statement caching will be enabled and maxStatements = 0 global limit will not be enforced, only the per-connection maximum.- See Also:
- Constant Field Values
-
PROP_URLDELIMITER
public static final String PROP_URLDELIMITER
(String) The delimiter used to separate the URLs of the brokers in the value of the url property.- See Also:
- Constant Field Values
-
DEFAULT_URL
public static final String DEFAULT_URL
(String) The connection url jdbc:com.nuodb://localhost:48004- See Also:
- Constant Field Values
-
DEFAULT_MAXSTATEMENTS
public static final int DEFAULT_MAXSTATEMENTS
(int) Sets default for the global maximum limit of statements per datasource to 0, which means no limit will be enforced.- See Also:
- Constant Field Values
-
DEFAULT_MAXSTATEMENTSPERCONNECTION
public static final int DEFAULT_MAXSTATEMENTSPERCONNECTION
(int) Sets default for per-connection maximum of prepared and callable statements to 0.- See Also:
- Constant Field Values
-
DEFAULT_INITIALSIZE
public static final long DEFAULT_INITIALSIZE
(long) Sets default for initial number of connections established during datasource initialization to 10.- See Also:
- Constant Field Values
-
ALL_PROPERTIES
public static final String[] ALL_PROPERTIES
Array of all properties recognized and accepted by this datasource.
-
DRIVER_URL_PREFIX
public static final String DRIVER_URL_PREFIX
- See Also:
- Constant Field Values
-
DRIVER_CLASS_NAME
public static final String DRIVER_CLASS_NAME
- See Also:
- Constant Field Values
-
HIBERNATE_DRIVER_URL_PREFIX
public static final String HIBERNATE_DRIVER_URL_PREFIX
- See Also:
- Constant Field Values
-
HIBERNATE_DRIVER_CLASS_NAME
public static final String HIBERNATE_DRIVER_CLASS_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DataSource
public DataSource()
Creates a new data source, initialized from the default properties The connection and statement pool are configured but the initial connections are started when getConnection() is called.
-
DataSource
public DataSource(Properties info)
Creates a new data source, initialized from the provided properties And starts a connection and statement pool.- Parameters:
info- the properties to use as initialization values
-
-
Method Detail
-
setProperties
public void setProperties(Properties info)
-
getLogWriter
public PrintWriter getLogWriter()
Retrieves the log writer for thisDataSourceobject used by theStandardLogger.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceConnectionPoolDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- the log writer for this data source or null if logging is disabled.
-
setLogWriter
public void setLogWriter(PrintWriter logWriter)
Sets the log writer of the standard logger forDataSourceobject to the givenjava.io.PrintWriterobject. The standard logger can also be set through the initialization propertystandardLogger.logWriteras string file name or print writer object.- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceConnectionPoolDataSource- Specified by:
setLogWriterin interfaceDataSource- Parameters:
logWriter- the new log writer; to disable logging, set to null
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getLoginTimeout
public int getLoginTimeout()
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceConnectionPoolDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Returns:
- the data source login time limit in seconds.
-
setLoginTimeout
public void setLoginTimeout(int loginTimeout)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceConnectionPoolDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Parameters:
loginTimeout- the data source login time limit in seconds.
-
getParentLogger
public Logger getParentLogger()
Gets the parent logger of all the loggers used by this data source. The parent logger is namedcom.nuodb.jdbcand is returned by theLoggerManager.getParentLogger().- Specified by:
getParentLoggerin interfaceCommonDataSource- Returns:
- the parent Logger for this data source
-
isWrapperFor
public boolean isWrapperFor(Class<?> type) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> type) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
Returns connection proxy using the default user and password specified in the initialization properties. Calling connection.close() on the proxy will return connection to the connection pool.- Specified by:
getConnectionin interfaceDataSource- Returns:
- a connection to the data source
- Throws:
SQLException- if a database access error occurs
-
getConnection
public Connection getConnection(String user, String password) throws SQLException
Returns connection proxy created using provided user and password. Calling connection.close() on the proxy will return connection to the connection pool.- Specified by:
getConnectionin interfaceDataSource- Parameters:
user- the database user on whose behalf the connection is being madepassword- the user's password- Returns:
- a connection to the data source
- Throws:
SQLException- if a database access error occurs
-
createConnectionHelper
public com.nuodb.jdbc.DataSource.ConnectionHelper createConnectionHelper(com.nuodb.jdbc.ConnectionKey connectionKey)
-
getPooledConnection
public PooledConnection getPooledConnection() throws SQLException
Establishes a physical database connection that can be used as a pooled connection using the default user and password specified in the initialization properties.- Specified by:
getPooledConnectionin interfaceConnectionPoolDataSource- Returns:
- object that is a physical connection to the database
- Throws:
SQLException- if a database access error occurs
-
getPooledConnection
public PooledConnection getPooledConnection(String user, String password) throws SQLException
Establishes a physical database connection that can be used as a pooled connection.- Specified by:
getPooledConnectionin interfaceConnectionPoolDataSource- Parameters:
user- the database user on whose behalf the connection is being madepassword- the user's password- Returns:
- object that is a physical connection to the database
- Throws:
SQLException- if a database access error occurs
-
connectionsAreIdentical
public static boolean connectionsAreIdentical(Connection lhs, Connection rhs)
Checks whether two connection proxies point to the same connection in the pool- Parameters:
lhs- object onerhs- object two- Returns:
- true if the objects are identical
-
getPoolIdleConnectionSize
public long getPoolIdleConnectionSize()
Get the number of idle connections in the pool- Returns:
- the number of idle connections in the pool
-
getPoolActiveConnectionSize
public long getPoolActiveConnectionSize()
Get the number of active connections in the pool- Returns:
- the number of active connections in the pool
-
setUrl
public void setUrl(String url)
Sets the URL of the NuoDB broker, optionally containing multiple brokers jdbc:com.nuodb://{broker}:{port}, {broker}:{port}, .../{database}, that will be contacted in case the primary one is unreachable This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
url- The connection url.
-
setUrlDelimiter
public void setUrlDelimiter(String urlDelimiter)
Sets the delimiter used to separate the URLs of the brokers in the value of the url property. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
urlDelimiter- the character used to separate URL of brokers in the connection url.
-
setUser
public void setUser(String user)
Sets the connection username to be passed to our JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
user- The connection username.
-
setUsername
public void setUsername(String username)
Sets the username to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
username- The connection username.
-
setPassword
public void setPassword(String password)
Sets the connection password to be passed to the JDBC driver to establish a connection, unless DataSource.getConnection(username, password) is used. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
password- The connection password.
-
setSchema
public void setSchema(String schema)
Sets the default schema of connections created by this pool. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
schema- The default schema for connections in this pool.
-
setDefaultSchema
public void setDefaultSchema(String schema)
Sets the default schema of connections created by this pool. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
schema- The default schema for connections in this pool.
-
setSQLEngine
public void setSQLEngine(String engine)
Sets the SQL engine of connections created by this pool. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
password- The connection password.
-
setDefaultReadOnly
public void setDefaultReadOnly(Boolean defaultReadOnly)
Sets the default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
defaultReadOnly- The default read-only state of connections created by this pool.
-
setDefaultAutoCommit
public void setDefaultAutoCommit(Boolean defaultAutoCommit)
Sets the default auto-commit state of connections created by this pool. If not set, default is JDBC driver default (If not set then the setAutoCommit method will not be called.) This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
defaultAutoCommit- The default auto-commit state of connections created by this pool.
-
setInitialSize
public void setInitialSize(long initialSize)
Sets the initial number of connections that are created when the pool is started. Default value is 10 This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
initialSize- The initial number of connections that are created when the pool is started.
-
setMaxActive
public void setMaxActive(long maxActive)
Sets the maximum number of active connections that can be allocated from this pool at the same time. The default value is 100; if set to 0, there is no limit This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
maxActive- The maximum number of active connections that can be allocated from this pool at the same time.
-
setMaxIdle
public void setMaxIdle(long maxIdle)
Sets the maximum number of connections that should be kept in the pool at all times. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
maxIdle- The maximum number of connections that should be kept in the pool at all times.
-
setMinIdle
public void setMinIdle(long minIdle)
Sets the minimum number of established connections that should be kept in the pool at all times. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
minIdle- The minimum number of established connections that should be kept in the pool at all times.
-
setMaxWait
public void setMaxWait(long maxWait)
Sets the maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
maxWait- The value of maxWait in milliseconds.
-
setMaxAge
public void setMaxAge(long maxAge)
Sets the time in milliseconds to keep this connection. When a connection is returned to the pool, the pool will check to see if the now - time-when-connected has reached PROP_MAXAGE, and if so, it closes the connection rather than returning it to the pool. The default value is 300000 (5 minutes). Setting it to 0 means that connections will be left open and no age check will be done. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
maxAge- The value of maxAge in milliseconds.
-
setMaxStatementsPerConnection
public void setMaxStatementsPerConnection(long maxStatementsPerConnection)
Sets the number of statements cached for a single pooled connection. If the property is non-zero, statement caching will be enabled and maxStatements = 0 global limit will not be enforced, only the per-connection maximum. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
maxStatementsPerConnection- The number of statements cached for a single pooled connection.
-
setTestOnReturn
public void setTestOnReturn(boolean testOnReturn)
Sets the indication of whether objects will be validated before being returned to the pool. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. The default value is false. This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
testOnReturn- The indication of whether objects will be validated before being returned to the pool.
-
setTestOnBorrow
public void setTestOnBorrow(boolean testOnBorrow)
Sets the indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. Default value is false. In order to have a more efficient validation, see PROP_VALIDATIONINTERVAL This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
testOnBorrow- The indication of whether objects will be validated before being borrowed from the pool.
-
setTestWhileIdle
public void setTestWhileIdle(boolean testWhileIdle)
Sets the indication of whether objects will be validated by the idle object evictor. If an object fails to validate, it will be dropped from the pool. NOTE - for a true value to have any effect, the PROP_VALIDATIONQUERY parameter must be set to a non-null string. The default value is false.In order to have a more efficient validation, see PROP_VALIDATIONINTERVAL This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
testWhileIdle- The indication of whether objects will be validated by the idle object evictor.
-
setValidationQuery
public void setValidationQuery(String validationQuery)
Sets the SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query does not have to return any data, it just can't throw a SQLException. The default value is null. Example value is SELECT 1 FROM DUAL This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
validationQuery- The SQL query that will be used to validate connections.
-
setValidationInterval
public void setValidationInterval(long validationInterval)
Sets the validation interval. To avoid excess validation, only run validation at most at this frequency - time in milliseconds. If a connection is due for validation, but has been validated previously within this interval, it will not be validated again. The default value is 30000 (30 seconds). This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
validationInterval- The validation interval in milliseconds.
-
setTimeBetweenEvictionRunsMillis
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Sets the number of milliseconds to sleep between runs of the idle connection validation/cleaner thread. This value should not be set under 1 second. It dictates how often we check for idle, abandoned connections, and how often we validate idle connections. The default value is 5000 (5 seconds). This method cannot be used used once the data source is initialized (i.e; at least one connection in the pool has been made successfully.)- Parameters:
timeBetweenEvictionRunsMillis- The number of milliseconds to sleep between runs of the idle connection validation/cleaner thread.
-
-