- All Implemented Interfaces:
Serializable
,Wrapper
,Referenceable
,CommonDataSource
,DataSource
,AttachmentProperties
,BaseProperties
,DatabaseConnectionProperties
,FirebirdConnectionProperties
DataSource
interface. Connections
are physically opened in DataSource.getConnection()
method and
physically closed in Connection.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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected FBDataSource
protected final FBManagedConnectionFactory
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance using the default GDS type (PURE_JAVA).FBSimpleDataSource
(GDSType type) Creates an instance using the specified GDS type. -
Method Summary
Modifier and TypeMethodDescriptionAn unmodifiable view on the connection properties held by this BaseProperties implementation.getBooleanProperty
(String name) Retrieves aboolean
property value by name.Get JDBC connection with default credentials.getConnection
(String username, String password) Get JDBC connection with the specified credentials.protected DataSource
Get underlying connection factory (an instance ofFBDataSource
class) that will provide JDBC connections.Get description of this datasource.getIntProperty
(String name) Retrieves anint
property value by name.getProperty
(String name) Retrieves a string property value by name.getTransactionParameters
(int isolation) Get the transaction parameter buffer corresponding to the current connection request information.boolean
isWrapperFor
(Class<?> iface) void
setBooleanProperty
(String name, Boolean value) Sets aboolean
property by name.void
setDescription
(String description) Set description of this datasource.void
setIntProperty
(String name, Integer value) Sets anint
property by name.void
setNonStandardProperty
(String propertyMapping) Set the property that does not have corresponding setter method.void
setProperty
(String name, String value) Sets a property by name.void
setTransactionParameters
(int isolation, TransactionParameterBuffer tpb) Set transaction parameters for the specified transaction isolation level.<T> T
Methods inherited from class org.firebirdsql.ds.AbstractConnectionPropertiesDataSource
getAuthPlugins, getBlobBufferSize, getCharSet, getConnectTimeout, getDatabaseName, getDataTypeBind, getDbCryptConfig, getDecfloatRound, getDecfloatTraps, getDefaultIsolation, getDefaultTransactionIsolation, getEnableProtocol, getEncoding, getGeneratedKeysEnabled, getLoginTimeout, getPageCacheSize, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getReportSQLWarnings, getRoleName, getScrollableCursor, getServerBatchBufferSize, getServerName, getSessionTimeZone, getSocketBufferSize, getSocketFactory, getSoTimeout, getSqlDialect, getTpbMapping, getType, getUser, getUserName, getWireCrypt, isAllowTxStmts, isAsyncFetch, isColumnLabelForName, isCreateDatabaseIfNotExist, isDefaultResultSetHoldable, isExtendedMetadata, isIgnoreProcedureType, isUseCatalogAsPackage, isUseFirebirdAutocommit, isUseServerBatch, isUseStreamBlobs, isWireCompression, setAllowTxStmts, setAsyncFetch, setAuthPlugins, setBlobBufferSize, setCharSet, setColumnLabelForName, setConnectTimeout, setCreateDatabaseIfNotExist, setDatabaseName, setDataTypeBind, setDbCryptConfig, setDecfloatRound, setDecfloatTraps, setDefaultIsolation, setDefaultResultSetHoldable, setDefaultTransactionIsolation, setEnableProtocol, setEncoding, setExtendedMetadata, setGeneratedKeysEnabled, setIgnoreProcedureType, setLoginTimeout, setPageCacheSize, setParallelWorkers, setPassword, setPortNumber, setProcessId, setProcessName, setReportSQLWarnings, setRoleName, setScrollableCursor, setServerBatchBufferSize, setServerName, setSessionTimeZone, setSocketBufferSize, setSocketFactory, setSoTimeout, setSqlDialect, setTpbMapping, setType, setUseCatalogAsPackage, 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
-
Field Details
-
mcf
-
ds
-
description
-
-
Constructor Details
-
FBSimpleDataSource
public FBSimpleDataSource()Creates an instance using the default GDS type (PURE_JAVA). -
FBSimpleDataSource
Creates an instance using the specified GDS type.- Parameters:
type
- GDS type
-
-
Method Details
-
getTransactionParameters
Description copied from interface:FirebirdConnectionProperties
Get the transaction parameter buffer corresponding to the current connection request information.- Specified by:
getTransactionParameters
in interfaceFirebirdConnectionProperties
- Parameters:
isolation
- transaction isolation level for which TPB should be returned.- Returns:
- instance of
TransactionParameterBuffer
.
-
setTransactionParameters
Description copied from interface:FirebirdConnectionProperties
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 interfaceFirebirdConnectionProperties
- Parameters:
isolation
- transaction isolation level.tpb
- instance ofTransactionParameterBuffer
containing transaction parameters.
-
setNonStandardProperty
Description copied from interface:FirebirdConnectionProperties
Set the property that does not have corresponding setter method.- Specified by:
setNonStandardProperty
in interfaceFirebirdConnectionProperties
- Parameters:
propertyMapping
- parameter value in thepropertyName[=propertyValue]
form, this allows setting non-standard parameters using configuration files.
-
getProperty
Description copied from interface:BaseProperties
Retrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not
null
. Forint
orboolean
the string equivalent is returned.- Specified by:
getProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Value of the property, or
null
when not set or not a known property
-
setProperty
Description copied from interface:BaseProperties
Sets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
int
orboolean
properties, the appropriate conversions are applied. Usingnull
will reset to the default value. Forboolean
properties, an empty string is taken to meantrue
.- Specified by:
setProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getIntProperty
Description copied from interface:BaseProperties
Retrieves anint
property 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
int
instead of checking if something is actually anint
property- Specified by:
getIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setIntProperty
Description copied from interface:BaseProperties
Sets anint
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getBooleanProperty
Description copied from interface:BaseProperties
Retrieves aboolean
property 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
boolean
instead of checking if something is actually aboolean
property- Specified by:
getBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setBooleanProperty
Description copied from interface:BaseProperties
Sets aboolean
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
connectionPropertyValues
Description copied from interface:BaseProperties
An 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:
connectionPropertyValues
in interfaceBaseProperties
- Returns:
- An unmodifiable view on the property values held in this properties instance
-
getReference
- Specified by:
getReference
in interfaceReferenceable
- Throws:
NamingException
-
getConnection
Get JDBC connection with default credentials.- Specified by:
getConnection
in interfaceDataSource
- Returns:
- new JDBC connection.
- Throws:
SQLException
- if something went wrong.
-
getConnection
Get JDBC connection with the specified credentials.- Specified by:
getConnection
in interfaceDataSource
- Parameters:
username
- username for the connection.password
- password for the connection.- Returns:
- new JDBC connection.
- Throws:
SQLException
- if something went wrong.
-
getDescription
Get description of this datasource.- Returns:
- description of this datasource.
-
setDescription
Set description of this datasource.- Parameters:
description
- description of this datasource.
-
getDataSource
Get underlying connection factory (an instance ofFBDataSource
class) that will provide JDBC connections.- Returns:
- JDBC connection factory.
- Throws:
SQLException
- if something went wrong.
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-