Class FBSimpleDataSource
- java.lang.Object
-
- org.firebirdsql.ds.RootCommonDataSource
-
- org.firebirdsql.ds.AbstractConnectionPropertiesDataSource
-
- org.firebirdsql.ds.FBSimpleDataSource
-
- All Implemented Interfaces:
java.io.Serializable,java.sql.Wrapper,javax.naming.Referenceable,javax.sql.CommonDataSource,javax.sql.DataSource,AttachmentProperties,BaseProperties,DatabaseConnectionProperties,FirebirdConnectionProperties
public class FBSimpleDataSource extends AbstractConnectionPropertiesDataSource implements javax.sql.DataSource, java.io.Serializable, javax.naming.Referenceable
This is a simple implementation ofDataSourceinterface. Connections are physically opened inDataSource.getConnection()method and physically closed inConnection.close()method.If you need a standalone connection pool, consider using a connection pool implementation like HikariCP, c3p0 or DBCP.
- Author:
- Roman Rokytskyy, David Jencks
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringdescriptionprotected FBDataSourcedsprotected FBManagedConnectionFactorymcf
-
Constructor Summary
Constructors Constructor Description FBSimpleDataSource()Creates an instance using the default GDS type (PURE_JAVA).FBSimpleDataSource(GDSType type)Creates an instance using the specified GDS type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Map<ConnectionProperty,java.lang.Object>connectionPropertyValues()An unmodifiable view on the connection properties held by this BaseProperties implementation.java.lang.IntegergetBlobBufferLength()Deprecated.UseAbstractConnectionPropertiesDataSource.getBlobBufferSize(); will be removed in Jaybird 6java.lang.BooleangetBooleanProperty(java.lang.String name)Retrieves abooleanproperty value by name.java.sql.ConnectiongetConnection()Get JDBC connection with default credentials.java.sql.ConnectiongetConnection(java.lang.String username, java.lang.String password)Get JDBC connection with the specified credentials.protected javax.sql.DataSourcegetDataSource()Get underlying connection factory (in our case instance ofFBDataSourceclass) that will provide JDBC connections.java.lang.StringgetDescription()Get description of this datasource.java.lang.IntegergetIntProperty(java.lang.String name)Retrieves anintproperty value by name.java.lang.StringgetProperty(java.lang.String name)Retrieves a string property value by name.javax.naming.ReferencegetReference()TransactionParameterBuffergetTransactionParameters(int isolation)Get the transaction parameter buffer corresponding to the current connection request information.booleanisWrapperFor(java.lang.Class<?> iface)voidsetBlobBufferLength(java.lang.Integer length)Deprecated.UseAbstractConnectionPropertiesDataSource.setBlobBufferSize(int); will be removed in Jaybird 6voidsetBooleanProperty(java.lang.String name, java.lang.Boolean value)Sets abooleanproperty by name.voidsetDescription(java.lang.String description)Set description of this datasource.voidsetIntProperty(java.lang.String name, java.lang.Integer value)Sets anintproperty by name.voidsetNonStandardProperty(java.lang.String propertyMapping)Set the property that does not have corresponding setter method.voidsetProperty(java.lang.String name, java.lang.String value)Sets a property by name.voidsetTransactionParameters(int isolation, TransactionParameterBuffer tpb)Set transaction parameters for the specified transaction isolation level.<T> Tunwrap(java.lang.Class<T> iface)-
Methods inherited from class org.firebirdsql.ds.AbstractConnectionPropertiesDataSource
getAuthPlugins, getBlobBufferSize, getBuffersNumber, getCharSet, getConnectTimeout, getDatabase, getDatabaseName, getDataTypeBind, getDbCryptConfig, getDecfloatRound, getDecfloatTraps, getDefaultIsolation, getDefaultTransactionIsolation, getEncoding, getGeneratedKeysEnabled, getLoginTimeout, getPageCacheSize, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getScrollableCursor, getServerBatchBufferSize, getServerName, getSessionTimeZone, getSocketBufferSize, getSoTimeout, getSqlDialect, getTpbMapping, getType, getUser, getUserName, getWireCrypt, isColumnLabelForName, isDefaultResultSetHoldable, isIgnoreProcedureType, isTimestampUsesLocalTimezone, isUseFirebirdAutocommit, isUseServerBatch, isUseStreamBlobs, isWireCompression, setAuthPlugins, setBlobBufferSize, setBuffersNumber, setCharSet, setColumnLabelForName, setConnectTimeout, setDatabase, setDatabaseName, setDataTypeBind, setDbCryptConfig, setDecfloatRound, setDecfloatTraps, setDefaultIsolation, setDefaultResultSetHoldable, setDefaultTransactionIsolation, setEncoding, setGeneratedKeysEnabled, setIgnoreProcedureType, setLoginTimeout, setPageCacheSize, setPassword, setPortNumber, setProcessId, setProcessName, setRoleName, setScrollableCursor, setServerBatchBufferSize, setServerName, setSessionTimeZone, setSocketBufferSize, setSoTimeout, setSqlDialect, setTimestampUsesLocalTimezone, setTpbMapping, setType, setUseFirebirdAutocommit, setUser, setUserName, setUseServerBatch, setUseStreamBlobs, setWireCompression, setWireCrypt
-
Methods inherited from class org.firebirdsql.ds.RootCommonDataSource
getLogWriter, getParentLogger, setLogWriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
getBooleanProperty, getIntProperty, getProperty
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLogger
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
-
Methods inherited from interface org.firebirdsql.jdbc.FirebirdConnectionProperties
getNonStandardProperty, setNonStandardProperty
-
-
-
-
Field Detail
-
mcf
protected final FBManagedConnectionFactory mcf
-
ds
protected transient FBDataSource ds
-
description
protected java.lang.String description
-
-
Constructor Detail
-
FBSimpleDataSource
public FBSimpleDataSource()
Creates an instance using the default GDS type (PURE_JAVA).
-
FBSimpleDataSource
public FBSimpleDataSource(GDSType type)
Creates an instance using the specified GDS type.- Parameters:
type- GDS type
-
-
Method Detail
-
getBlobBufferLength
@Deprecated public java.lang.Integer getBlobBufferLength()
Deprecated.UseAbstractConnectionPropertiesDataSource.getBlobBufferSize(); will be removed in Jaybird 6Get buffer length for the BLOB fields.- Returns:
- length of BLOB buffer.
-
setBlobBufferLength
@Deprecated public void setBlobBufferLength(java.lang.Integer length)
Deprecated.UseAbstractConnectionPropertiesDataSource.setBlobBufferSize(int); will be removed in Jaybird 6Set BLOB buffer length. This value influences the performance when working with BLOB fields.- Parameters:
length- new length of the BLOB buffer.
-
getTransactionParameters
public TransactionParameterBuffer getTransactionParameters(int isolation)
Description copied from interface:FirebirdConnectionPropertiesGet the transaction parameter buffer corresponding to the current connection request information.- Specified by:
getTransactionParametersin interfaceFirebirdConnectionProperties- Parameters:
isolation- transaction isolation level for which TPB should be returned.- Returns:
- instance of
TransactionParameterBuffer.
-
setTransactionParameters
public void setTransactionParameters(int isolation, TransactionParameterBuffer tpb)Description copied from interface:FirebirdConnectionPropertiesSet transaction parameters for the specified transaction isolation level. The specified TPB is used as a default mapping for the specified isolation level.- Specified by:
setTransactionParametersin interfaceFirebirdConnectionProperties- Parameters:
isolation- transaction isolation level.tpb- instance ofTransactionParameterBuffercontaining transaction parameters.
-
setNonStandardProperty
public void setNonStandardProperty(java.lang.String propertyMapping)
Description copied from interface:FirebirdConnectionPropertiesSet the property that does not have corresponding setter method.- Specified by:
setNonStandardPropertyin interfaceFirebirdConnectionProperties- Parameters:
propertyMapping- parameter value in thepropertyName[=propertyValue]form, this allows setting non-standard parameters using configuration files.
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not
null. Forintorbooleanthe string equivalent is returned.- Specified by:
getPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Value of the property, or
nullwhen not set or not a known property
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)Description copied from interface:BasePropertiesSets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
intorbooleanproperties, the appropriate conversions are applied. Usingnullwill reset to the default value. Forbooleanproperties, an empty string is taken to meantrue.- Specified by:
setPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getIntProperty
public java.lang.Integer getIntProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves anintproperty value by name.For properties with an explicit default, this method should return the integer presentation of that default. For implementation simplicity, it is allowed to convert any string property to
intinstead of checking if something is actually anintproperty- Specified by:
getIntPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setIntProperty
public void setIntProperty(java.lang.String name, java.lang.Integer value)Description copied from interface:BasePropertiesSets anintproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setIntPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getBooleanProperty
public java.lang.Boolean getBooleanProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves abooleanproperty value by name.For properties with an explicit default, this method should return the boolean presentation of that default. For implementation simplicity, it is allowed to convert any string property to
booleaninstead of checking if something is actually anintproperty- Specified by:
getBooleanPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setBooleanProperty
public void setBooleanProperty(java.lang.String name, java.lang.Boolean value)Description copied from interface:BasePropertiesSets abooleanproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setBooleanPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
connectionPropertyValues
public java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues()
Description copied from interface:BasePropertiesAn unmodifiable view on the connection properties held by this BaseProperties implementation.Be aware, implementations can have additional properties that are not mapped from
ConnectionProperty. Such properties will need to be retrieved in an implementation-specific manner.- Specified by:
connectionPropertyValuesin interfaceBaseProperties- Returns:
- An unmodifiable view on the property values held in this properties instance
-
getReference
public javax.naming.Reference getReference() throws javax.naming.NamingException- Specified by:
getReferencein interfacejavax.naming.Referenceable- Throws:
javax.naming.NamingException
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionGet JDBC connection with default credentials.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Returns:
- new JDBC connection.
- Throws:
java.sql.SQLException- if something went wrong.
-
getConnection
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLExceptionGet JDBC connection with the specified credentials.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Parameters:
username- username for the connection.password- password for the connection.- Returns:
- new JDBC connection.
- Throws:
java.sql.SQLException- if something went wrong.
-
getDescription
public java.lang.String getDescription()
Get description of this datasource.- Returns:
- description of this datasource.
-
setDescription
public void setDescription(java.lang.String description)
Set description of this datasource.- Parameters:
description- description of this datasource.
-
getDataSource
protected javax.sql.DataSource getDataSource() throws java.sql.SQLExceptionGet underlying connection factory (in our case instance ofFBDataSourceclass) that will provide JDBC connections.- Returns:
- JDBC connection factory.
- Throws:
java.sql.SQLException- if something went wrong.
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
-