org.firebirdsql.ds

## 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 of `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:
  Serialized Form

### Field Summary

Fields
`protected java.lang.String` `description`
`protected FBDataSource` `ds`
`protected FBManagedConnectionFactory` `mcf`

### Constructor Summary

Constructors
Constructor and 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
`java.util.Map<ConnectionProperty,java.lang.Object>` `connectionPropertyValues()` An unmodifiable view on the connection properties held by this BaseProperties implementation.
`java.lang.Integer` `getBlobBufferLength()` Deprecated. Use `AbstractConnectionPropertiesDataSource.getBlobBufferSize()`; will be removed in Jaybird 6
`java.lang.Boolean` `getBooleanProperty(java.lang.String name)` Retrieves a `boolean` property value by name.
`java.sql.Connection` `getConnection()` Get JDBC connection with default credentials.
`java.sql.Connection` `getConnection(java.lang.String username, java.lang.String password)` Get JDBC connection with the specified credentials.
`protected javax.sql.DataSource` `getDataSource()` Get underlying connection factory (in our case instance of `FBDataSource` class) that will provide JDBC connections.
`java.lang.String` `getDescription()` Get description of this datasource.
`java.lang.Integer` `getIntProperty(java.lang.String name)` Retrieves an `int` property value by name.
`java.lang.String` `getProperty(java.lang.String name)` Retrieves a string property value by name.
`javax.naming.Reference` `getReference()`
`TransactionParameterBuffer` `getTransactionParameters(int isolation)` Get the transaction parameter buffer corresponding to the current connection request information.
`boolean` `isWrapperFor(java.lang.Class<?> iface)`
`void` `setBlobBufferLength(java.lang.Integer length)` Deprecated. Use `AbstractConnectionPropertiesDataSource.setBlobBufferSize(int)`; will be removed in Jaybird 6
`void` `setBooleanProperty(java.lang.String name, java.lang.Boolean value)` Sets a `boolean` property by name.
`void` `setDescription(java.lang.String description)` Set description of this datasource.
`void` `setIntProperty(java.lang.String name, java.lang.Integer value)` Sets an `int` property by name.
`void` `setNonStandardProperty(java.lang.String propertyMapping)` Set the property that does not have corresponding setter method.
`void` `setProperty(java.lang.String name, java.lang.String value)` Sets a property by name.
`void` `setTransactionParameters(int isolation, TransactionParameterBuffer tpb)` Set transaction parameters for the specified transaction isolation level.
`<T> T` `unwrap(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, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getScrollableCursor, getServerBatchBufferSize, getServerName, getSessionTimeZone, getSocketBufferSize, getSoTimeout, getSqlDialect, getTpbMapping, getType, getUser, getUserName, getWireCrypt, isColumnLabelForName, isDefaultResultSetHoldable, isExtendedMetadata, isIgnoreProcedureType, isTimestampUsesLocalTimezone, isUseFirebirdAutocommit, isUseServerBatch, isUseStreamBlobs, isWireCompression, setAuthPlugins, setBlobBufferSize, setBuffersNumber, setCharSet, setColumnLabelForName, setConnectTimeout, setDatabase, setDatabaseName, setDataTypeBind, setDbCryptConfig, setDecfloatRound, setDecfloatTraps, setDefaultIsolation, setDefaultResultSetHoldable, setDefaultTransactionIsolation, setEncoding, setExtendedMetadata, setGeneratedKeysEnabled, setIgnoreProcedureType, setLoginTimeout, setPageCacheSize, setParallelWorkers, 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 javax.sql.CommonDataSource

`getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter`

### Methods inherited from interface org.firebirdsql.jdbc.FirebirdConnectionProperties

`getNonStandardProperty, setNonStandardProperty`

### Methods inherited from interface org.firebirdsql.jaybird.props.BaseProperties

`getBooleanProperty, getIntProperty, getProperty`

### 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. Use `AbstractConnectionPropertiesDataSource.getBlobBufferSize()`; will be removed in Jaybird 6
Get buffer length for the BLOB fields.

Returns:
  length of BLOB buffer.

#### setBlobBufferLength

    @Deprecated
    public void setBlobBufferLength(java.lang.Integer length)

Deprecated. Use `AbstractConnectionPropertiesDataSource.setBlobBufferSize(int)`; will be removed in Jaybird 6
Set 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: `FirebirdConnectionProperties`
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`.

#### setTransactionParameters

    public void setTransactionParameters(int isolation,
                                         TransactionParameterBuffer tpb)

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 interface `FirebirdConnectionProperties`
Parameters:
  `isolation` - transaction isolation level.
  `tpb` - instance of `TransactionParameterBuffer` containing transaction parameters.

#### setNonStandardProperty

    public void setNonStandardProperty(java.lang.String propertyMapping)

Description copied from interface: `FirebirdConnectionProperties`
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.

#### getProperty

    public java.lang.String getProperty(java.lang.String name)

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`. For `int` or `boolean` the string equivalent is returned.

Specified by:
  `getProperty` in interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
Returns:
  Value of the property, or `null` when not set or not a known property

#### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.String value)

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` or `boolean` properties, the appropriate conversions are applied. Using `null` will reset to the default value. For `boolean` properties, an empty string is taken to mean `true`.

Specified by:
  `setProperty` in interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
  `value` - Property value (use `null` to apply default)

#### getIntProperty

    public java.lang.Integer getIntProperty(java.lang.String name)

Description copied from interface: `BaseProperties`
Retrieves an `int` 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 an `int` property

Specified by:
  `getIntProperty` in interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
Returns:
  Integer with value of the property, or `null` when not set

#### setIntProperty

    public void setIntProperty(java.lang.String name,
                               java.lang.Integer value)

Description copied from interface: `BaseProperties`
Sets an `int` 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 interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
  `value` - Property value (use `null` to apply default)

#### getBooleanProperty

    public java.lang.Boolean getBooleanProperty(java.lang.String name)

Description copied from interface: `BaseProperties`
Retrieves a `boolean` 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 an `int` property

Specified by:
  `getBooleanProperty` in interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
Returns:
  Integer with value of the property, or `null` when not set

#### setBooleanProperty

    public void setBooleanProperty(java.lang.String name,
                                   java.lang.Boolean value)

Description copied from interface: `BaseProperties`
Sets a `boolean` 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 interface `BaseProperties`
Parameters:
  `name` - Property name (not `null` or empty)
  `value` - Property value (use `null` to apply default)

#### connectionPropertyValues

    public java.util.Map<ConnectionProperty,java.lang.Object> 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 interface `BaseProperties`
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:
  `getReference` in interface `javax.naming.Referenceable`
Throws:
  `javax.naming.NamingException`

#### getConnection

    public java.sql.Connection getConnection()
                                      throws java.sql.SQLException

Get JDBC connection with default credentials.

Specified by:
  `getConnection` in interface `javax.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.SQLException

Get JDBC connection with the specified credentials.

Specified by:
  `getConnection` in interface `javax.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.SQLException

Get underlying connection factory (in our case instance of `FBDataSource` class) 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:
  `isWrapperFor` in interface `java.sql.Wrapper`
Throws:
  `java.sql.SQLException`

#### unwrap

    public <T> T unwrap(java.lang.Class<T> iface)
                 throws java.sql.SQLException

Specified by:
  `unwrap` in interface `java.sql.Wrapper`
Throws:
  `java.sql.SQLException`