org.firebirdsql.pool
Class FBWrappingDataSource

java.lang.Object
  extended byorg.firebirdsql.pool.FBWrappingDataSource
All Implemented Interfaces:
javax.sql.DataSource, FirebirdPool, javax.naming.spi.ObjectFactory, javax.resource.Referenceable, javax.naming.Referenceable, java.io.Serializable

public class FBWrappingDataSource
extends java.lang.Object
implements javax.sql.DataSource, javax.naming.spi.ObjectFactory, javax.resource.Referenceable, java.io.Serializable, FirebirdPool

Implementation of DataSource including connection pooling. Following properties are supported:

Author:
Roman Rokytskyy
See Also:
Serialized Form

Constructor Summary
FBWrappingDataSource()
          Create instance of this class.
 
Method Summary
protected  void finalize()
          Finalize this instance.
 int getBlobBufferSize()
           
 int getBlockingTimeout()
           
 java.lang.String getCharSet()
           
 java.sql.Connection getConnection()
          Get JDBC connection from this data source.
 java.sql.Connection getConnection(java.lang.String user, java.lang.String password)
          Get JDBC connection for the specified user name and password.
 int getConnectionCount()
          Deprecated. Confusing name. Use getFreeSize() instead.
 java.lang.String getDatabase()
           
 javax.naming.Reference getDefaultReference()
          Get default JNDI reference for this datasource.
 java.lang.String getDescription()
           
 java.lang.String getEncoding()
           
 int getFreeSize()
           
 int getIdleTimeout()
          Deprecated. non-standard name, use getMaxIdleTime().
 java.lang.String getIsolation()
           
 int getLoginTimeout()
          Get login timeout.
 java.io.PrintWriter getLogWriter()
          Get log writer.
 int getMaxConnections()
          Deprecated. non-standard name, use getMaxPoolSize().
 int getMaxIdleTime()
           
 int getMaxPoolSize()
           
 int getMaxStatements()
           
 int getMinConnections()
          Deprecated. non-standard name, use getMinPoolSize()
 int getMinPoolSize()
           
 java.lang.String getNonStandardProperty(java.lang.String key)
           
 java.lang.Object getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
          Get object instance for the specified name in the specified context.
 java.lang.String getPassword()
           
 int getPingInterval()
           
 boolean getPooling()
          Deprecated. use isPooling() method.
 javax.naming.Reference getReference()
          Get JDNI reference.
 java.lang.String getRoleName()
           
 int getSocketBufferSize()
           
 java.lang.String getSqlRole()
          Deprecated. please use getRoleName() instead.
 int getTotalSize()
           
 java.lang.String getTpbMapping()
           
 int getTransactionIsolationLevel()
           
 java.lang.String getType()
           
 java.lang.String getUserName()
           
 int getWorkingSize()
           
 boolean isKeepStatements()
           
 boolean isPooling()
           
 boolean isStatementPooling()
           
 void setBlobBufferSize(int blobBufferSizeValue)
           
 void setBlockingTimeout(int blockingTimeoutValue)
           
 void setCharSet(java.lang.String charSet)
           
 void setDatabase(java.lang.String databaseValue)
           
 void setDescription(java.lang.String descriptionValue)
           
 void setEncoding(java.lang.String encodingValue)
           
 void setIdleTimeout(int idleTimeoutValue)
          Deprecated. non-standard name, use setMaxIdleTime(int).
 void setIsolation(java.lang.String isolation)
           
 void setKeepStatements(boolean keepStatements)
           
 void setLoginTimeout(int seconds)
          Set login timeout.
 void setLogWriter(java.io.PrintWriter printWriter)
          Set log writer.
 void setMaxConnections(int maxConnections)
          Deprecated. non-standard name, use setMaxPoolSize(int).
 void setMaxIdleTime(int maxIdleTime)
           
 void setMaxPoolSize(int maxPoolSize)
           
 void setMaxStatements(int maxStatements)
           
 void setMinConnections(int minConnections)
          Deprecated. non-standard name, use setMinPoolSize(int)
 void setMinPoolSize(int minPoolSize)
           
 void setNonStandardProperty(java.lang.String propertyMapping)
           
 void setNonStandardProperty(java.lang.String key, java.lang.String value)
           
 void setPassword(java.lang.String passwordValue)
           
 void setPingInterval(int pingIntervalValue)
           
 void setPooling(boolean pooling)
           
 void setProperties(java.util.Properties props)
           
 void setReference(javax.naming.Reference reference)
          Set JNDI reference for this data source.
 void setRoleName(java.lang.String roleName)
           
 void setSocketBufferSize(int socketBufferSize)
           
 void setSqlRole(java.lang.String sqlRole)
          Deprecated. please use setRoleName(String) instead.
 void setStatementPooling(boolean statementPooling)
           
 void setTpbMapping(java.lang.String tpbMappingValue)
           
 void setTransactionIsolationLevel(int level)
           
 void setType(java.lang.String typeValue)
           
 void setUserName(java.lang.String userNameValue)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FBWrappingDataSource

public FBWrappingDataSource()
                     throws java.sql.SQLException
Create instance of this class.

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize this instance. This method will shut the pool down.

Throws:
java.lang.Throwable - if something went wrong.

shutdown

public void shutdown()
Specified by:
shutdown in interface FirebirdPool

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Get JDBC connection from this data source.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
instance of Connection.
Throws:
java.sql.SQLException - if connection cannot be obtained due to some reason.

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Get JDBC connection for the specified user name and password.

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException - if something went wrong.

getLoginTimeout

public int getLoginTimeout()
Get login timeout.

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
login timeout.

getLogWriter

public java.io.PrintWriter getLogWriter()
Get log writer.

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
instance of PrintWriter.

setLoginTimeout

public void setLoginTimeout(int seconds)
Set login timeout.

Specified by:
setLoginTimeout in interface javax.sql.DataSource
Parameters:
seconds - login timeout.

setLogWriter

public void setLogWriter(java.io.PrintWriter printWriter)
Set log writer.

Specified by:
setLogWriter in interface javax.sql.DataSource
Parameters:
printWriter - instance of PrintWriter.

getBlockingTimeout

public int getBlockingTimeout()
Specified by:
getBlockingTimeout in interface FirebirdPool

setBlockingTimeout

public void setBlockingTimeout(int blockingTimeoutValue)
Specified by:
setBlockingTimeout in interface FirebirdPool

getDatabase

public java.lang.String getDatabase()
Specified by:
getDatabase in interface FirebirdPool

setDatabase

public void setDatabase(java.lang.String databaseValue)
Specified by:
setDatabase in interface FirebirdPool

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String descriptionValue)

getEncoding

public java.lang.String getEncoding()
Specified by:
getEncoding in interface FirebirdPool

setEncoding

public void setEncoding(java.lang.String encodingValue)
Specified by:
setEncoding in interface FirebirdPool

getCharSet

public java.lang.String getCharSet()
Specified by:
getCharSet in interface FirebirdPool

setCharSet

public void setCharSet(java.lang.String charSet)
                throws java.sql.SQLException
Specified by:
setCharSet in interface FirebirdPool
Throws:
java.sql.SQLException

getMaxIdleTime

public int getMaxIdleTime()
Specified by:
getMaxIdleTime in interface FirebirdPool

setMaxIdleTime

public void setMaxIdleTime(int maxIdleTime)
Specified by:
setMaxIdleTime in interface FirebirdPool

getIdleTimeout

public int getIdleTimeout()
Deprecated. non-standard name, use getMaxIdleTime().


setIdleTimeout

public void setIdleTimeout(int idleTimeoutValue)
Deprecated. non-standard name, use setMaxIdleTime(int).


getMaxStatements

public int getMaxStatements()
Specified by:
getMaxStatements in interface FirebirdPool

setMaxStatements

public void setMaxStatements(int maxStatements)
Specified by:
setMaxStatements in interface FirebirdPool

getMaxPoolSize

public int getMaxPoolSize()
Specified by:
getMaxPoolSize in interface FirebirdPool

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
Specified by:
setMaxPoolSize in interface FirebirdPool

getMaxConnections

public int getMaxConnections()
Deprecated. non-standard name, use getMaxPoolSize().


setMaxConnections

public void setMaxConnections(int maxConnections)
Deprecated. non-standard name, use setMaxPoolSize(int).


getMinPoolSize

public int getMinPoolSize()
Specified by:
getMinPoolSize in interface FirebirdPool

setMinPoolSize

public void setMinPoolSize(int minPoolSize)
Specified by:
setMinPoolSize in interface FirebirdPool

getMinConnections

public int getMinConnections()
Deprecated. non-standard name, use getMinPoolSize()


setMinConnections

public void setMinConnections(int minConnections)
Deprecated. non-standard name, use setMinPoolSize(int)


isKeepStatements

public boolean isKeepStatements()

setKeepStatements

public void setKeepStatements(boolean keepStatements)

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface FirebirdPool

setPassword

public void setPassword(java.lang.String passwordValue)
Specified by:
setPassword in interface FirebirdPool

getTpbMapping

public java.lang.String getTpbMapping()
Specified by:
getTpbMapping in interface FirebirdPool

setTpbMapping

public void setTpbMapping(java.lang.String tpbMappingValue)
Specified by:
setTpbMapping in interface FirebirdPool

getUserName

public java.lang.String getUserName()
Specified by:
getUserName in interface FirebirdPool

setUserName

public void setUserName(java.lang.String userNameValue)
Specified by:
setUserName in interface FirebirdPool

getBlobBufferSize

public int getBlobBufferSize()
Specified by:
getBlobBufferSize in interface FirebirdPool

setBlobBufferSize

public void setBlobBufferSize(int blobBufferSizeValue)
Specified by:
setBlobBufferSize in interface FirebirdPool

getType

public java.lang.String getType()
Specified by:
getType in interface FirebirdPool

setType

public void setType(java.lang.String typeValue)
             throws java.sql.SQLException
Specified by:
setType in interface FirebirdPool
Throws:
java.sql.SQLException

getPingInterval

public int getPingInterval()
Specified by:
getPingInterval in interface FirebirdPool

setPingInterval

public void setPingInterval(int pingIntervalValue)
Specified by:
setPingInterval in interface FirebirdPool

getSocketBufferSize

public int getSocketBufferSize()
Specified by:
getSocketBufferSize in interface FirebirdPool

setSocketBufferSize

public void setSocketBufferSize(int socketBufferSize)
Specified by:
setSocketBufferSize in interface FirebirdPool

getRoleName

public java.lang.String getRoleName()
Specified by:
getRoleName in interface FirebirdPool

setRoleName

public void setRoleName(java.lang.String roleName)
Specified by:
setRoleName in interface FirebirdPool

getSqlRole

public java.lang.String getSqlRole()
Deprecated. please use getRoleName() instead.


setSqlRole

public void setSqlRole(java.lang.String sqlRole)
Deprecated. please use setRoleName(String) instead.


getNonStandardProperty

public java.lang.String getNonStandardProperty(java.lang.String key)
Specified by:
getNonStandardProperty in interface FirebirdPool

setNonStandardProperty

public void setNonStandardProperty(java.lang.String key,
                                   java.lang.String value)
Specified by:
setNonStandardProperty in interface FirebirdPool

setNonStandardProperty

public void setNonStandardProperty(java.lang.String propertyMapping)
Specified by:
setNonStandardProperty in interface FirebirdPool

getPooling

public boolean getPooling()
Deprecated. use isPooling() method.


isPooling

public boolean isPooling()
Specified by:
isPooling in interface FirebirdPool

setPooling

public void setPooling(boolean pooling)
Specified by:
setPooling in interface FirebirdPool

isStatementPooling

public boolean isStatementPooling()
Specified by:
isStatementPooling in interface FirebirdPool

setStatementPooling

public void setStatementPooling(boolean statementPooling)
Specified by:
setStatementPooling in interface FirebirdPool

getConnectionCount

public int getConnectionCount()
                       throws java.sql.SQLException
Deprecated. Confusing name. Use getFreeSize() instead.

Throws:
java.sql.SQLException

getFreeSize

public int getFreeSize()
                throws java.sql.SQLException
Specified by:
getFreeSize in interface FirebirdPool
Throws:
java.sql.SQLException

getWorkingSize

public int getWorkingSize()
                   throws java.sql.SQLException
Specified by:
getWorkingSize in interface FirebirdPool
Throws:
java.sql.SQLException

getTotalSize

public int getTotalSize()
                 throws java.sql.SQLException
Specified by:
getTotalSize in interface FirebirdPool
Throws:
java.sql.SQLException

getTransactionIsolationLevel

public int getTransactionIsolationLevel()
Specified by:
getTransactionIsolationLevel in interface FirebirdPool

setTransactionIsolationLevel

public void setTransactionIsolationLevel(int level)
Specified by:
setTransactionIsolationLevel in interface FirebirdPool

getIsolation

public java.lang.String getIsolation()
Specified by:
getIsolation in interface FirebirdPool

setIsolation

public void setIsolation(java.lang.String isolation)
                  throws java.sql.SQLException
Specified by:
setIsolation in interface FirebirdPool
Throws:
java.sql.SQLException

setProperties

public void setProperties(java.util.Properties props)

getObjectInstance

public java.lang.Object getObjectInstance(java.lang.Object obj,
                                          javax.naming.Name name,
                                          javax.naming.Context nameCtx,
                                          java.util.Hashtable environment)
                                   throws java.lang.Exception
Get object instance for the specified name in the specified context. This method constructs new datasource if obj represents Reference, whose factory class is equal to this class.

Specified by:
getObjectInstance in interface javax.naming.spi.ObjectFactory
Throws:
java.lang.Exception

getReference

public javax.naming.Reference getReference()
Get JDNI reference.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
instance of Reference.

setReference

public void setReference(javax.naming.Reference reference)
Set JNDI reference for this data source.

Specified by:
setReference in interface javax.resource.Referenceable
Parameters:
reference - JNDI reference.

getDefaultReference

public javax.naming.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.


Copyright © 2001 David Jencks and other authors. All rights reserved.