Class FBSimpleDataSource

  • All Implemented Interfaces:
    java.io.Serializable, java.sql.Wrapper, javax.naming.Referenceable, javax.resource.Referenceable, javax.sql.CommonDataSource, javax.sql.DataSource, FirebirdConnectionProperties

    public class FBSimpleDataSource
    extends RootCommonDataSource
    implements javax.sql.DataSource, java.io.Serializable, javax.resource.Referenceable, FirebirdConnectionProperties
    This is a simple implementation of DataSource interface. Connections are physically opened in DataSource.getConnection() method and physically closed in Connection.close() method.
    Version:
    1.0
    Author:
    Roman Rokytskyy, David Jencks
    See Also:
    Serialized Form
    • Constructor Detail

      • FBSimpleDataSource

        public FBSimpleDataSource()
        Create instance of this class.
      • FBSimpleDataSource

        public FBSimpleDataSource​(GDSType type)
        Create instance of this class.
    • Method Detail

      • getBlobBufferLength

        public java.lang.Integer getBlobBufferLength()
        Get buffer length for the BLOB fields.
        Returns:
        length of BLOB buffer.
      • setBlobBufferLength

        public void setBlobBufferLength​(java.lang.Integer length)
        Set BLOB buffer length. This value influences the performance when working with BLOB fields.
        Parameters:
        length - new length of the BLOB buffer.
      • getDatabaseName

        @Deprecated
        public java.lang.String getDatabaseName()
        Deprecated.
        use getDatabase() instead for the sake of naming compatibility.
        Get name of the database.
        Returns:
        database name, value is equal to the part of full JDBC URL without the jdbc:firebirdsql: part.
      • setDatabaseName

        @Deprecated
        public void setDatabaseName​(java.lang.String name)
        Deprecated.
        use setDatabase(String) instead for the sake of naming compatibility.
        Set database name.
        Parameters:
        name - connection URL without "jdbc:firebirdsql:" prefix ("//localhost:3050/c:/database/employee.fdb") for example).
      • getDatabase

        public java.lang.String getDatabase()
        Get name of the database.
        Specified by:
        getDatabase in interface FirebirdConnectionProperties
        Returns:
        database name, value is equal to the part of full JDBC URL without the jdbc:firebirdsql: part.
      • setDatabase

        public void setDatabase​(java.lang.String name)
        Set database name.
        Specified by:
        setDatabase in interface FirebirdConnectionProperties
        Parameters:
        name - connection URL without "jdbc:firebirdsql:" prefix ("//localhost:3050/c:/database/employee.fdb") for example).
      • getUser

        @Deprecated
        public java.lang.String getUser()
        Deprecated.
        use getUserName() instead for the sake of naming compatibility.
        Get user name that is used in getConnection() method.
        Returns:
        default user name.
      • setUser

        @Deprecated
        public void setUser​(java.lang.String user)
        Deprecated.
        use setUserName(String) instead for the sake of naming compatibility.
        Set user name that will be used in getConnection() method.
        Parameters:
        user - default user name.
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Set encoding for connections produced by this data source.
        Specified by:
        setEncoding in interface FirebirdConnectionProperties
        Parameters:
        encoding - encoding for the connection.
      • setTpbMapping

        public void setTpbMapping​(java.lang.String tpbMapping)
        Description copied from interface: FirebirdConnectionProperties
        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 the Connection interface and a comma-separated list of TPB parameters.

        Specified by:
        setTpbMapping in interface FirebirdConnectionProperties
        Parameters:
        tpbMapping - path to the properties file.
      • getBuffersNumber

        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.
      • getNonStandardProperty

        public java.lang.String getNonStandardProperty​(java.lang.String key)
        Description copied from interface: FirebirdConnectionProperties
        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.
      • getType

        public java.lang.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.
      • isTimestampUsesLocalTimezone

        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.
      • setBuffersNumber

        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.
      • setCharSet

        public void setCharSet​(java.lang.String charSet)
        Specified by:
        setCharSet in interface FirebirdConnectionProperties
        Parameters:
        charSet - Character set for the connection. Similar to encoding property, but accepts Java names instead of Firebird ones.
      • setDefaultIsolation

        public void setDefaultIsolation​(java.lang.String isolation)
        Description copied from interface: FirebirdConnectionProperties
        Set the default transaction isolation level as string. This method is complementary to the FirebirdConnectionProperties.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.
      • setNonStandardProperty

        public void setNonStandardProperty​(java.lang.String key,
                                           java.lang.String value)
        Description copied from interface: FirebirdConnectionProperties
        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.
      • 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.
      • setTimestampUsesLocalTimezone

        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.
      • setType

        public void setType​(java.lang.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.
      • setUseStandardUdf

        public void setUseStandardUdf​(boolean useStandardUdf)
        Specified by:
        setUseStandardUdf in interface FirebirdConnectionProperties
        Parameters:
        useStandardUdf - true if driver should assume that standard UDF are installed.
      • setUseStreamBlobs

        public void setUseStreamBlobs​(boolean useStreamBlobs)
        Specified by:
        setUseStreamBlobs in interface FirebirdConnectionProperties
        Parameters:
        useStreamBlobs - true if stream blobs should be created, otherwise false.
      • setWireCrypt

        public void setWireCrypt​(java.lang.String wireCrypt)
        Description copied from interface: FirebirdConnectionProperties
        Sets the wire encryption level.

        Values are defined by WireCrypt, values are handled case insensitive. Invalid values are accepted, but will cause an error when a connection is established.

        Specified by:
        setWireCrypt in interface FirebirdConnectionProperties
        Parameters:
        wireCrypt - Wire encryption level
      • setDbCryptConfig

        public void setDbCryptConfig​(java.lang.String dbCryptConfig)
        Description copied from interface: FirebirdConnectionProperties
        Sets the database encryption plugin configuration.
        Specified by:
        setDbCryptConfig in interface FirebirdConnectionProperties
        Parameters:
        dbCryptConfig - Database encryption plugin configuration, meaning plugin specific
      • setAuthPlugins

        public void setAuthPlugins​(java.lang.String authPlugins)
        Description copied from interface: FirebirdConnectionProperties
        Sets the authentication plugins to try.

        Invalid names are skipped during authentication.

        Specified by:
        setAuthPlugins in interface FirebirdConnectionProperties
        Parameters:
        authPlugins - comma-separated list of authentication plugins, or null for driver default
      • setGeneratedKeysEnabled

        public void setGeneratedKeysEnabled​(java.lang.String generatedKeysEnabled)
        Description copied from interface: FirebirdConnectionProperties
        Sets the generatedKeysEnabled configuration.
        Specified by:
        setGeneratedKeysEnabled in interface FirebirdConnectionProperties
        Parameters:
        generatedKeysEnabled - Generated keys support configuration: default (or null/empty), disabled, ignored, or a list of statement types to enable (possible values: insert, update, delete, update_or_insert, merge)
      • setDataTypeBind

        public void setDataTypeBind​(java.lang.String dataTypeBind)
        Description copied from interface: FirebirdConnectionProperties
        Sets the dataTypeBind configuration.

        If the value is explicitly set to a non-null value and the connected server is Firebird 4 or higher, this will configure the data type binding with the specified values using isc_dpb_set_bind, which is equivalent to executing SET BIND statements with the values.

        See also Firebird documentation for SET BIND.

        Specified by:
        setDataTypeBind in interface FirebirdConnectionProperties
        Parameters:
        dataTypeBind - Firebird 4+ data type bind configuration, a semicolon-separated list of <from-type> TO <to-type>
      • setSessionTimeZone

        public void setSessionTimeZone​(java.lang.String sessionTimeZone)
        Description copied from interface: FirebirdConnectionProperties
        Sets the sessionTimeZone.
        Specified by:
        setSessionTimeZone in interface FirebirdConnectionProperties
        Parameters:
        sessionTimeZone - Firebird 4+ session time zone name (we strongly suggest to use Java compatible names only), use "server" to use server default time zone (note: conversion will use JVM default time zone)
      • setIgnoreProcedureType

        public void setIgnoreProcedureType​(boolean ignoreProcedureType)
        Description copied from interface: FirebirdConnectionProperties
        Sets the value ignoreProcedureType.

        When set to true, the CallableStatement implementation in Jaybird will ignore metadata information about the stored procedure type and default to using EXECUTE PROCEDURE, unless the type is explicitly set using FirebirdCallableStatement.setSelectableProcedure(boolean). This can be useful in situations where a stored procedure is selectable, but tooling or code expects an executable stored procedure.

        Specified by:
        setIgnoreProcedureType in interface FirebirdConnectionProperties
        Parameters:
        ignoreProcedureType - true Ignore procedure type
      • isWireCompression

        public boolean isWireCompression()
        Description copied from interface: FirebirdConnectionProperties
        Get if wire compression should be enabled.

        Wire compression requires Firebird 3 or higher, and the server must have the zlib library. If compression cannot be negotiated, the connection will be made without wire compression.

        This property will be ignored for native connections. For native connections, the configuration in firebird.conf read by the client library will be used.

        Specified by:
        isWireCompression in interface FirebirdConnectionProperties
        Returns:
        true wire compression enabled
      • getReference

        public javax.naming.Reference getReference()
                                            throws javax.naming.NamingException
        Get previously set JNDI reference.
        Specified by:
        getReference in interface javax.naming.Referenceable
        Returns:
        instance of Reference set previously.
        Throws:
        javax.naming.NamingException - if something went wrong.
      • 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 - reference to set.
      • 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 - user name for the connection.
        password - password for the connection.
        Returns:
        new JDBC connection.
        Throws:
        java.sql.SQLException - if something went wrong.
      • getLoginTimeout

        public int getLoginTimeout()
                            throws java.sql.SQLException

        This property is an alias for the connectTimeout property.

        Specified by:
        getLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        getLoginTimeout in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • setLoginTimeout

        public void setLoginTimeout​(int loginTimeout)
                             throws java.sql.SQLException

        This property is an alias for the connectTimeout property.

        Specified by:
        setLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        setLoginTimeout in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • 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