Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.firebirdsql.pool.FBWrappingDataSource
public class FBWrappingDataSource
extends java.lang.Object
implements DataSource, ObjectFactory, Referenceable, Serializable, FirebirdPool
javax.sql.DataSource
including connection pooling.
Following properties are supported:
blobBufferSize
size of the buffer used to transfer BLOB data.
blockingTimeout
time in milliseconds during which getConnection()
method will
block if no free connection is in pool.
charSet
similar to encoding
, but takes Java character set name
instead of Firebird's encoding.
database
path to a database including the server name; for example
localhost/3050:c:/path/to/database.gdb
.
encoding
character encoding for the JDBC connection.
freeSize
read-only: gives amount of free connections in the pool, when 0, blocking
will occur if workingSize
is equal to maxPoolSize
.
isolation
default transaction isolation level for connections as string; possible
values are:
loginTimeout
property from javax.sql.DataSource
, in this context is a synonym
for blockingTimeout
(however value is specified in seconds).
maxIdleTime
time in milliseconds after which idle physical connection in the
pool is closed.
maxStatements
maximum number of pooled prepared statements, if 0, pooling is switched
off.
maxPoolSize
maximum number of physical connections that can be opened by this data
source.
minPoolSize
minimum number of connections that will remain open by this data source.
nonStandardProperty
a non-standard connection parameter in form name[=value]
.
password
password that is used to connect to database.
pingInterval
time interval during which connection will be proved for aliveness.
pooling
allows switching pooling off.
statementPooling
alternative way to switch statement pooling off.
socketBufferSize
size of the socket buffer in bytes. In some cases values used by JVM by
default are not optimal. This results in performance degradation
(especially when you transfer big BLOBs). Usually 8192 bytes provides
good results.
roleName
SQL role name.
tpbMapping
mapping of the TPB parameters to JDBC transaction isolation levels.
transactionIsolationLevel
default transaction isolation level, number from java.sql.Connection
interface.
totalSize
total number of allocated connections.
type
type of connection that will be created. There are four possible types:
pure Java (or type 4), type 2 that will use Firebird client library to
connect to the database, local-mode type 2 driver, and embedded that
will use embedded engine (access to local databases). Possible values
are (case insensitive):
"PURE_JAVA"
or "TYPE4"
for pure Java (type 4) JDBC connections;
"NATIVE"
or "TYPE2"
to use Firebird client library;
"LOCAL"
to use Firebird client library in local-mode (IPC link to server);
"EMBEDDED"
to use embedded engine.
userName
name of the user that will be used to access the database.
workingSize
number of connections that are in use (e.g. were obtained using
getConnection()
method, but not yet closed).
Constructor Summary | |
|
Method Summary | |
protected void |
|
int | |
int |
|
int | |
String | |
Connection |
|
Connection |
|
int |
|
String | |
DatabaseParameterBuffer |
|
String |
|
Reference |
|
int |
|
String | |
String | |
int | |
int |
|
String |
|
PrintWriter |
|
int |
|
int |
|
int |
|
int |
|
int | |
int |
|
int |
|
String |
|
Object |
|
String | |
int |
|
String |
|
boolean |
|
Reference |
|
int |
|
String | |
int | |
String | |
String |
|
int | |
String |
|
int |
|
TransactionParameterBuffer |
|
String |
|
String | |
String | |
int | |
boolean | |
boolean | |
boolean |
|
boolean |
|
boolean |
|
boolean | |
boolean | |
boolean | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void finalize() throws Throwable
Finalize this instance. This method will shut the pool down.
public int getBlobBufferSize()
- Specified by:
- getBlobBufferSize in interface FirebirdConnectionProperties
- Returns:
- BLOB buffer size in bytes.
public int getBlockingTimeout()
Get time during whichjavax.sql.ConnectionPoolDataSource.getPooledConnection()
can block. By default method blocks forever.
- Specified by:
- getBlockingTimeout in interface FirebirdPool
- getBlockingTimeout in interface ConnectionPoolConfiguration
- Returns:
- pool blocking timeout in milliseconds,
Integer.MAX_VALUE
indicates blocking forever.
public int getBuffersNumber()
- Specified by:
- getBuffersNumber in interface FirebirdConnectionProperties
- Returns:
- number of cache buffers that should be allocated for this connection, should be specified for ClassicServer instances, SuperServer has a server-wide configuration parameter.
public String getCharSet()
- Specified by:
- getCharSet in interface FirebirdConnectionProperties
- Returns:
- Character set for the connection.
public Connection getConnection() throws SQLException
Get JDBC connection from this data source.
- Returns:
- instance of
Connection
.
public Connection getConnection(String user, String password) throws SQLException
Get JDBC connection for the specified user name and password.of {@link Connection}
public int getConnectionCount() throws SQLException
Deprecated. Confusing name. Use
getFreeSize()
instead.
public String getDatabase()
- Specified by:
- getDatabase in interface FirebirdConnectionProperties
- Returns:
- path to the database including the server name and the port, if needed.
public DatabaseParameterBuffer getDatabaseParameterBuffer() throws SQLException
Get the database parameter buffer corresponding to the current connection request information.
- Specified by:
- getDatabaseParameterBuffer in interface FirebirdConnectionProperties
- Returns:
- instance of
DatabaseParameterBuffer
.
public String getDefaultIsolation()
Get the default transaction isolation level as string. This method is complementary to theFirebirdConnectionProperties.getDefaultTransactionIsolation()
, however it takes a string as parameter instead of a numeric constant.
- Specified by:
- getDefaultIsolation in interface FirebirdConnectionProperties
- Returns:
- default transaction isolation as string.
public Reference getDefaultReference()
Get default JNDI reference for this datasource. This method is called if datasource is used in non-JCA environment.
- Returns:
- instance of
Reference
containing all information that allows to reconstruct the datasource.
public int getDefaultTransactionIsolation()
Get the default transaction isolation level. This is the transaction isolation level for the newly created connections.
- Specified by:
- getDefaultTransactionIsolation in interface FirebirdConnectionProperties
- Returns:
- default transaction isolation level.
public String getDescription()
public String getEncoding()
- Specified by:
- getEncoding in interface FirebirdConnectionProperties
- Returns:
- Character encoding for the connection.
public int getFreeSize() throws SQLException
- Specified by:
- getFreeSize in interface FirebirdPool
public int getIdleTimeout()
Deprecated. non-standard name, use
getMaxIdleTime()
.
- Specified by:
- getIdleTimeout in interface ConnectionPoolConfiguration
public PrintWriter getLogWriter()
Get log writer.
- Returns:
- instance of
PrintWriter
.
public int getLoginTimeout()
Get login timeout.
- Returns:
- login timeout.
public int getMaxConnections()
Deprecated. non-standard name, use
getMaxPoolSize()
.
- Specified by:
- getMaxConnections in interface ConnectionPoolConfiguration
public int getMaxIdleTime()
Get time after which idle connections will be deallocated.
- Specified by:
- getMaxIdleTime in interface FirebirdPool
- getMaxIdleTime in interface ConnectionPoolConfiguration
- Returns:
- idle timeout in milliseconds,
Integer.MAX_VALUE
indicates that idle connections are not removed.
public int getMaxPoolSize()
Get maximum number of physical connections that can be simultaneously open.
- Specified by:
- getMaxPoolSize in interface FirebirdPool
- getMaxPoolSize in interface ConnectionPoolConfiguration
- Returns:
- maximum number of simultaneously open physical database connections, 0 if no limit exists.
public int getMaxStatements()
- Specified by:
- getMaxStatements in interface FirebirdPool
public int getMinConnections()
Deprecated. non-standard name, use
getMinPoolSize()
- Specified by:
- getMinConnections in interface ConnectionPoolConfiguration
public int getMinPoolSize()
Get minimum number of open JDBC connections that will be created when pool is started.
- Specified by:
- getMinPoolSize in interface FirebirdPool
- getMinPoolSize in interface ConnectionPoolConfiguration
- Returns:
- minimum number of open JDBC connections to open at startup.
public String getNonStandardProperty(String key)
Get the property that does not have corresponding getter method by its name.
- Specified by:
- getNonStandardProperty in interface FirebirdConnectionProperties
- Parameters:
key
- name of the property to get.
- Returns:
- value of the property.
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
Get object instance for the specified name in the specified context. This method constructs new datasource ifobj
representsReference
, whose factory class is equal to this class.
public String getPassword()
- Specified by:
- getPassword in interface FirebirdConnectionProperties
- Returns:
- password corresponding to the specified user name.
public int getPingInterval()
Get time interval after which connection should be pinged.
- Specified by:
- getPingInterval in interface FirebirdPool
- getPingInterval in interface ConnectionPoolConfiguration
- Returns:
- number of milliseconds in the ping interval.
public String getPingStatement()
Get SQL statement that will be used to ping connection. Ping SQL statement returns exactly one row without throwing an exception. Ping SQL statement must not influence the outcome of a transaction. Examples of ping SQL statements:
- Oracle:
"SELECT CAST(1 AS INTEGER) FROM DUAL"
- Firebird:
"SELECT CAST(1 AS INTEGER) FROM RDB$DATABASE"
- Specified by:
- getPingStatement in interface ConnectionPoolConfiguration
- Returns:
- SQL statement that will be used to ping connection.
public Reference getReference()
Get JDNI reference.
- Returns:
- instance of
Reference
.
public int getRetryInterval()
Get interval of getting connections retries. It might happen that pool contains no free connection. In order not to wait until connection is returned into the pool, pool will try to obtain connection again and again with the interval returned by this method. Default value is 1000 (1 sec).
- Specified by:
- getRetryInterval in interface ConnectionPoolConfiguration
- Returns:
- retry interval in milliseconds.
public String getRoleName()
- Specified by:
- getRoleName in interface FirebirdConnectionProperties
- Returns:
- SQL role to use.
public int getSocketBufferSize()
- Specified by:
- getSocketBufferSize in interface FirebirdConnectionProperties
- Returns:
- socket buffer size in bytes, or -1 is not specified.
public String getSqlDialect()
- Specified by:
- getSqlDialect in interface FirebirdConnectionProperties
- Returns:
- SQL dialect of the client.
public int getTotalSize() throws SQLException
- Specified by:
- getTotalSize in interface FirebirdPool
public String getTpbMapping()
Get the used TPB mapping.
- Specified by:
- getTpbMapping in interface FirebirdConnectionProperties
- Returns:
- path to the TPB mapping.
public int getTransactionIsolationLevel()
Deprecated. Use
getDefaultTransactionIsolation()
instead.
public TransactionParameterBuffer getTransactionParameters(int isolation)
Get the transaction parameter buffer corresponding to the current connection request information.
- Specified by:
- getTransactionParameters in interface FirebirdConnectionProperties
- Parameters:
isolation
- transaction isolation level for which TPB should be returned.
- Returns:
- instance of
TransactionParameterBuffer
.
public String getType()
- Specified by:
- getType in interface FirebirdConnectionProperties
- Returns:
- type of the connection, for example, "PURE_JAVA", "LOCAL", "EMBEDDED", depends on the GDS implementations installed in the system.
public String getUseTranslation()
- Specified by:
- getUseTranslation in interface FirebirdConnectionProperties
- Returns:
- path to the character translation table.
public String getUserName()
- Specified by:
- getUserName in interface FirebirdConnectionProperties
- Returns:
- name of the user that will be used when connecting to the database.
public int getWorkingSize() throws SQLException
- Specified by:
- getWorkingSize in interface FirebirdPool
public boolean isDefaultResultSetHoldable()
- Specified by:
- isDefaultResultSetHoldable in interface FirebirdConnectionProperties
public boolean isKeepStatements()
public boolean isPingable()
Check if this pool supports pingable connections. Pingable connections are used to correctly check if connection is still alive or not.
- Specified by:
- isPingable in interface ConnectionPoolConfiguration
- Returns:
true
if this pool supports pingable connections.
public boolean isPooling()
Check if this connection pool uses connection pooling, or just implements JDBC 2.0 SE interfaces. By default pooling is on. It might make sense to set pooling off to check performance degradation in test environment. It could be also used in the environment where physical connection must be closed right after usage, however using JDBC 2.0 SE interfaces is either a requirement or is simpler than standardjava.sql.Driver
.
- Specified by:
- isPooling in interface FirebirdPool
- isPooling in interface ConnectionPoolConfiguration
- Returns:
true
if pooling is enabled.
public boolean isStatementPooling()
Check if this connection pool provides also prepared statement pooling. By default prepared statement pooling is enabled, however there might be situations where statement pooling is not desired, for example in environments where database can quickly run out of handles and fast handle reuse is required.
- Specified by:
- isStatementPooling in interface FirebirdPool
- isStatementPooling in interface ConnectionPoolConfiguration
- Returns:
true
if prepared statement pooling is enabled.
public boolean isTimestampUsesLocalTimezone()
- Specified by:
- isTimestampUsesLocalTimezone in interface FirebirdConnectionProperties
- Returns:
true
if the Jaybird 1.0 handling of the calendar in corresponding setters. This is also compatible with MySQL calendar treatment.
public boolean isUseStandardUdf()
- Specified by:
- isUseStandardUdf in interface FirebirdConnectionProperties
- Returns:
true
if driver should assume that standard UDF are installed.
public boolean isUseStreamBlobs()
- Specified by:
- isUseStreamBlobs in interface FirebirdConnectionProperties
- Returns:
true
if stream blobs should be created, otherwisefalse
.
public void setBlobBufferSize(int bufferSize)
- Specified by:
- setBlobBufferSize in interface FirebirdConnectionProperties
- Parameters:
bufferSize
- size of the BLOB buffer in bytes.
public void setBlockingTimeout(int blockingTimeoutValue)
- Specified by:
- setBlockingTimeout in interface FirebirdPool
public void setBuffersNumber(int buffersNumber)
- Specified by:
- setBuffersNumber in interface FirebirdConnectionProperties
- Parameters:
buffersNumber
- number of cache buffers that should be allocated for this connection, should be specified for ClassicServer instances, SuperServer has a server-wide configuration parameter.
public void setCharSet(String charSet)
- Specified by:
- setCharSet in interface FirebirdConnectionProperties
- Parameters:
charSet
- Character set for the connection. Similar toencoding
property, but accepts Java names instead of Firebird ones.
public void setDatabase(String database)
- Specified by:
- setDatabase in interface FirebirdConnectionProperties
- Parameters:
database
- path to the database including the server name and the port, if needed.
public void setDefaultIsolation(String isolation)
Set the default transaction isolation level as string. This method is complementary to theFirebirdConnectionProperties.setDefaultTransactionIsolation(int)
, however it takes a string as parameter instead of a numeric constant. Following strings are allowed:
"TRANSACTION_READ_COMMITTED"
for a READ COMMITTED isolation level."TRANSACTION_REPEATABLE_READ"
for a REPEATABLE READ isolation level."TRANSACTION_SERIALIZABLE"
for a SERIALIZABLE isolation level.
- Specified by:
- setDefaultIsolation in interface FirebirdConnectionProperties
- Parameters:
isolation
- string constant representing a default isolation level.
public void setDefaultResultSetHoldable(boolean isHoldable)
- Specified by:
- setDefaultResultSetHoldable in interface FirebirdConnectionProperties
public void setDefaultTransactionIsolation(int defaultIsolationLevel)
Set the default transaction isolation level.
- Specified by:
- setDefaultTransactionIsolation in interface FirebirdConnectionProperties
- Parameters:
defaultIsolationLevel
- default transaction isolation level.
public void setDescription(String descriptionValue)
public void setEncoding(String encoding)
- Specified by:
- setEncoding in interface FirebirdConnectionProperties
- Parameters:
encoding
- Character encoding for the connection. See Firebird documentation for more information.
public void setIdleTimeout(int idleTimeoutValue)
Deprecated. non-standard name, use
setMaxIdleTime(int)
.
public void setIsolation(String isolation) throws SQLException
Deprecated. Use
setDefaultIsolation(String)
instead.
public void setKeepStatements(boolean keepStatements)
public void setLogWriter(PrintWriter printWriter)
Set log writer.
- Parameters:
printWriter
- instance ofPrintWriter
.
public void setLoginTimeout(int seconds)
Set login timeout.
- Parameters:
seconds
- login timeout.
public void setMaxConnections(int maxConnections)
Deprecated. non-standard name, use
setMaxPoolSize(int)
.
public void setMaxIdleTime(int maxIdleTime)
- Specified by:
- setMaxIdleTime in interface FirebirdPool
public void setMaxPoolSize(int maxPoolSize)
- Specified by:
- setMaxPoolSize in interface FirebirdPool
public void setMaxStatements(int maxStatements)
- Specified by:
- setMaxStatements in interface FirebirdPool
public void setMinConnections(int minConnections)
Deprecated. non-standard name, use
setMinPoolSize(int)
public void setMinPoolSize(int minPoolSize)
- Specified by:
- setMinPoolSize in interface FirebirdPool
public void setNonStandardProperty(String propertyMapping)
Set the property that does not have corresponding setter method.
- Specified by:
- setNonStandardProperty in interface FirebirdConnectionProperties
- Parameters:
propertyMapping
- parameter value in the ?propertyName[=propertyValue]? form, this allows setting non-standard parameters using configuration files.
public void setNonStandardProperty(String key, String value)
Set the property that does not have corresponding setter method.
- Specified by:
- setNonStandardProperty in interface FirebirdConnectionProperties
- Parameters:
key
- name of the property to set.value
- value of the property.
public void setPassword(String password)
- Specified by:
- setPassword in interface FirebirdConnectionProperties
- Parameters:
password
- password corresponding to the specified user name.
public void setPingInterval(int pingIntervalValue)
- Specified by:
- setPingInterval in interface FirebirdPool
public void setPingStatement(String pingStatement)
public void setProperties(Properties props)
public void setReference(Reference reference)
Set JNDI reference for this data source.
- Parameters:
reference
- JNDI reference.
public void setRetryInterval(int retryInterval)
public void setRoleName(String roleName)
- Specified by:
- setRoleName in interface FirebirdConnectionProperties
- Parameters:
roleName
- SQL role to use.
public void setSocketBufferSize(int socketBufferSize)
- Specified by:
- setSocketBufferSize in interface FirebirdConnectionProperties
- Parameters:
socketBufferSize
- socket buffer size in bytes.
public void setSqlDialect(String sqlDialect)
- Specified by:
- setSqlDialect in interface FirebirdConnectionProperties
- Parameters:
sqlDialect
- SQL dialect of the client.
public void setStatementPooling(boolean statementPooling)
- Specified by:
- setStatementPooling in interface FirebirdPool
public void setTimestampUsesLocalTimezone(boolean timestampUsesLocalTimezone)
- Specified by:
- setTimestampUsesLocalTimezone in interface FirebirdConnectionProperties
- Parameters:
timestampUsesLocalTimezone
-true
if the Jaybird 1.0 handling of the calendar in corresponding setters. This is also compatible with MySQL calendar treatment.
public void setTpbMapping(String tpbMapping)
Set path to the properties file with the TPB mapping. The path begins with the protocol specification followed by the path to the resource. A special protocol"res:"
should be used to specify resource in the classpath. For the compatibility reasons, if no protocol is specified, classpath is used by default. Properties file contains a mapping between the transaction isolation level (name of the constant in thejava.sql.Connection
interface and a comma-separated list of TPB parameters.
- Specified by:
- setTpbMapping in interface FirebirdConnectionProperties
- Parameters:
tpbMapping
- path to the properties file.
public void setTransactionIsolationLevel(int level)
Deprecated. Use
setDefaultTransactionIsolation(int)
instead.
public void setTransactionParameters(int isolation, TransactionParameterBuffer tpb)
Set transaction parameters for the specified transaction isolation level. The specified TPB is used as a default mapping for the specified isolation level.
- Specified by:
- setTransactionParameters in interface FirebirdConnectionProperties
- Parameters:
isolation
- transaction isolation level.tpb
- instance ofTransactionParameterBuffer
containing transaction parameters.
public void setType(String type)
- Specified by:
- setType in interface FirebirdConnectionProperties
- Parameters:
type
- type of the connection, for example, "PURE_JAVA", "LOCAL", "EMBEDDED", depends on the GDS implementations installed in the system.
public void setUseStandardUdf(boolean useStandardUdf)
- Specified by:
- setUseStandardUdf in interface FirebirdConnectionProperties
- Parameters:
useStandardUdf
-true
if driver should assume that standard UDF are installed.
public void setUseStreamBlobs(boolean useStreamBlobs)
- Specified by:
- setUseStreamBlobs in interface FirebirdConnectionProperties
- Parameters:
useStreamBlobs
-true
if stream blobs should be created, otherwisefalse
.
public void setUseTranslation(String translationPath)
- Specified by:
- setUseTranslation in interface FirebirdConnectionProperties
- Parameters:
translationPath
- path to the character translation table.
public void setUserName(String userName)
- Specified by:
- setUserName in interface FirebirdConnectionProperties
- Parameters:
userName
- name of the user that will be used when connecting to the database.