Package SQLite.JDBC2z

Class JDBCConnection

    • Field Detail

      • db

        protected SQLite.JDBC2z.DatabaseX db
        Open database.
      • url

        protected String url
        Database URL.
      • enc

        protected String enc
        Character encoding.
      • vfs

        protected String vfs
        SQLite 3 VFS to use.
      • autocommit

        protected boolean autocommit
        Autocommit flag, true means autocommit.
      • intrans

        protected boolean intrans
        In-transaction flag. Can be true only when autocommit false.
      • timeout

        protected int timeout
        Timeout for Database.exec()
      • useJulian

        protected boolean useJulian
        Use double/julian date representation.
    • Method Detail

      • busy

        public boolean busy​(String table,
                            int count)
        Description copied from interface: BusyHandler
        Invoked when a table is locked by another process or thread. The method should return true for waiting until the table becomes unlocked, or false in order to abandon the action.

        Specified by:
        busy in interface BusyHandler
        Parameters:
        table - the name of the locked table
        count - number of times the table was locked
      • busy3

        protected boolean busy3​(SQLite.JDBC2z.DatabaseX db,
                                int count)
      • getSQLiteDatabase

        public Database getSQLiteDatabase()
      • createStatement

        public Statement createStatement()
        Description copied from interface: Connection
        Returns a new instance of Statement for issuing SQL commands to the remote database.

        ResultSets generated by the returned statement will default to type ResultSet.TYPE_FORWARD_ONLY and concurrency level ResultSet.CONCUR_READ_ONLY.

        Specified by:
        createStatement in interface Connection
        Returns:
        a Statement object with default settings.
        See Also:
        ResultSet
      • getMetaData

        public DatabaseMetaData getMetaData()
                                     throws SQLException
        Description copied from interface: Connection
        Gets the metadata about the database referenced by this connection. The returned DatabaseMetaData describes the database topography, available stored procedures, SQL syntax and so on.
        Specified by:
        getMetaData in interface Connection
        Returns:
        a DatabaseMetaData object containing the database description.
        Throws:
        SQLException - if there is a problem accessing the a database.
      • close

        public void close()
                   throws SQLException
        Description copied from interface: Connection
        Causes the instant release of all database and driver connection resources associated with this object. Any subsequent invocations of this method have no effect.

        It is strongly recommended that all connections are closed before they are dereferenced by the application ready for garbage collection. Although the finalize method of the connection closes the connection before garbage collection takes place, it is not advisable to leave the close operation to take place in this way. Mainly because undesired side-effects may appear.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Connection
        Throws:
        SQLException - if there is a problem accessing the database.
      • isClosed

        public boolean isClosed()
                         throws SQLException
        Description copied from interface: Connection
        Returns a boolean indicating whether or not this connection is in the closed state. The closed state may be entered into as a consequence of a successful invocation of the Connection.close() method or else if an error has occurred that prevents the connection from functioning normally.
        Specified by:
        isClosed in interface Connection
        Returns:
        true if closed, otherwise false.
        Throws:
        SQLException - if there is a problem accessing the database.
      • isReadOnly

        public boolean isReadOnly()
                           throws SQLException
        Description copied from interface: Connection
        Returns a boolean indicating whether or not this connection is currently in the read-only state.
        Specified by:
        isReadOnly in interface Connection
        Returns:
        true if in read-only state, otherwise false.
        Throws:
        SQLException - if there is a problem accessing the database.
      • commit

        public void commit()
                    throws SQLException
        Description copied from interface: Connection
        Commits all of the changes made since the last commit or rollback of the associated transaction. All locks in the database held by this connection are also relinquished. Calling this operation on connection objects in auto-commit mode leads to an error.
        Specified by:
        commit in interface Connection
        Throws:
        SQLException - if there is a problem accessing the database or if the target connection instance is in auto-commit mode.
      • getAutoCommit

        public boolean getAutoCommit()
                              throws SQLException
        Description copied from interface: Connection
        Returns a boolean indicating whether or not this connection is in the auto-commit operating mode.
        Specified by:
        getAutoCommit in interface Connection
        Returns:
        true if auto-commit is on, otherwise false.
        Throws:
        SQLException - if there is a problem accessing the database.
      • getCatalog

        public String getCatalog()
                          throws SQLException
        Description copied from interface: Connection
        Gets this Connection object's current catalog name.
        Specified by:
        getCatalog in interface Connection
        Returns:
        the catalog name. null if there is no catalog name.
        Throws:
        SQLException - if there is a problem accessing the database.
      • getWarnings

        public SQLWarning getWarnings()
                               throws SQLException
        Description copied from interface: Connection
        Gets the first instance of any SQLWarning objects that may have been created in the use of this connection. If at least one warning has occurred then this operation returns the first one reported. A null indicates that no warnings have occurred.

        By invoking the SQLWarning.getNextWarning() method of the returned SQLWarning object it is possible to obtain all of this connection's warning objects.

        Specified by:
        getWarnings in interface Connection
        Returns:
        the first warning as an SQLWarning object (may be null).
        Throws:
        SQLException - if there is a problem accessing the database or if the call has been made on a connection which has been previously closed.
      • nativeSQL

        public String nativeSQL​(String sql)
                         throws SQLException
        Description copied from interface: Connection
        Returns a string representation of the input SQL statement sql expressed in the underlying system's native SQL syntax.
        Specified by:
        nativeSQL in interface Connection
        Parameters:
        sql - the JDBC form of an SQL statement.
        Returns:
        the SQL statement in native database format.
        Throws:
        SQLException - if there is a problem accessing the database
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql)
                                           throws SQLException
        Description copied from interface: Connection
        Returns a new instance of PreparedStatement that may be used any number of times to execute parameterized requests on the database server.

        Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

        By default, ResultSets from the returned object will be ResultSet.TYPE_FORWARD_ONLY type with a ResultSet.CONCUR_READ_ONLY mode of concurrency.

        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - the SQL statement.
        Returns:
        the PreparedStatement containing the supplied SQL statement.
        Throws:
        SQLException - if there is a problem accessing the database.
      • rollback

        public void rollback()
                      throws SQLException
        Description copied from interface: Connection
        Rolls back all updates made so far in this transaction and relinquishes all acquired database locks. It is an error to invoke this operation when in auto-commit mode.
        Specified by:
        rollback in interface Connection
        Throws:
        SQLException - if there is a problem with the database or if the method is called while in auto-commit mode of operation.
      • setAutoCommit

        public void setAutoCommit​(boolean ac)
                           throws SQLException
        Description copied from interface: Connection
        Sets this connection's auto-commit mode on or off.

        Putting a Connection into auto-commit mode means that all associated SQL statements are run and committed as separate transactions. By contrast, setting auto-commit to off means that associated SQL statements get grouped into transactions that need to be completed by explicit calls to either the Connection.commit() or Connection.rollback() methods.

        Auto-commit is the default mode for new connection instances.

        When in this mode, commits will automatically occur upon successful SQL statement completion or upon successful completion of an execute. Statements are not considered successfully completed until all associated ResultSets and output parameters have been obtained or closed.

        Calling this operation during an uncommitted transaction will result in it being committed.

        Specified by:
        setAutoCommit in interface Connection
        Parameters:
        ac - boolean indication of whether to put the target connection into auto-commit mode (true) or not ( false).
        Throws:
        SQLException - if there is a problem accessing the database.
      • setCatalog

        public void setCatalog​(String catalog)
                        throws SQLException
        Description copied from interface: Connection
        Sets the catalog name for this connection. This is used to select a subspace of the database for future work. If the driver does not support catalog names, this method is ignored.
        Specified by:
        setCatalog in interface Connection
        Parameters:
        catalog - the catalog name to use.
        Throws:
        SQLException - if there is a problem accessing the database.
      • setReadOnly

        public void setReadOnly​(boolean ro)
                         throws SQLException
        Description copied from interface: Connection
        Sets this connection to read-only mode.

        This serves as a hint to the driver, which can enable database optimizations.

        Specified by:
        setReadOnly in interface Connection
        Parameters:
        ro - true to set the Connection to read only mode. false disables read-only mode.
        Throws:
        SQLException - if there is a problem accessing the database.
      • getTypeMap

        public Map<String,​Class<?>> getTypeMap()
                                              throws SQLException
        Description copied from interface: Connection
        Returns the type mapping associated with this Connection object. The type mapping must be set on the application level.
        Specified by:
        getTypeMap in interface Connection
        Returns:
        the Type Map as a java.util.Map.
        Throws:
        SQLException - if there is a problem accessing the database.
      • setTypeMap

        public void setTypeMap​(Map map)
                        throws SQLException
        Description copied from interface: Connection
        Sets the TypeMap for this connection. The input map should contain mappings between complex Java and SQL types.
        Specified by:
        setTypeMap in interface Connection
        Parameters:
        map - the new type map.
        Throws:
        SQLException - if there is a problem accessing the database or if map is not an instance of Map.
      • setSavepoint

        public Savepoint setSavepoint()
                               throws SQLException
        Description copied from interface: Connection
        Creates an unnamed Savepoint in the current transaction.
        Specified by:
        setSavepoint in interface Connection
        Returns:
        a Savepoint object for this savepoint.
        Throws:
        SQLException - if there is a problem accessing the database.
      • setSavepoint

        public Savepoint setSavepoint​(String name)
                               throws SQLException
        Description copied from interface: Connection
        Creates a named Savepoint in the current transaction.
        Specified by:
        setSavepoint in interface Connection
        Parameters:
        name - the name to use for the new Savepoint.
        Returns:
        a Savepoint object for this savepoint.
        Throws:
        SQLException - if there is a problem accessing the database.
      • rollback

        public void rollback​(Savepoint x)
                      throws SQLException
        Description copied from interface: Connection
        Undoes all changes made after the supplied Savepoint object was set. This method should only be used when auto-commit mode is disabled.
        Specified by:
        rollback in interface Connection
        Parameters:
        x - the Savepoint to roll back to
        Throws:
        SQLException - if there is a problem accessing the database.
      • releaseSavepoint

        public void releaseSavepoint​(Savepoint x)
                              throws SQLException
        Description copied from interface: Connection
        Releases the specified savepoint from the present transaction. Once removed, the Savepoint is considered invalid and should not be referenced further.
        Specified by:
        releaseSavepoint in interface Connection
        Parameters:
        x - the object targeted for removal.
        Throws:
        SQLException - if there is a problem with accessing the database or if savepoint is considered not valid in this transaction.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int autokeys)
                                           throws SQLException
        Description copied from interface: Connection
        Creates a default PreparedStatement that can retrieve automatically generated keys. Parameter autoGeneratedKeys may be used to tell the driver whether such keys should be made accessible. This is only relevant when the sql statement is an insert statement.

        An SQL statement which may have IN parameters can be stored and precompiled in a PreparedStatement. The PreparedStatement can then be then be used to execute the statement multiple times in an efficient way.

        Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

        By default, ResultSets from the returned object will be ResultSet.TYPE_FORWARD_ONLY type with a ResultSet.CONCUR_READ_ONLY mode of concurrency.

        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - the SQL statement.
        autokeys - one of the following generated key options:
        Returns:
        a new PreparedStatement instance representing the input SQL statement.
        Throws:
        SQLException - if there is a problem accessing the database.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int[] colIndexes)
                                           throws SQLException
        Description copied from interface: Connection
        Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array. If sql is an SQL INSERT statement, the parameter columnIndexes is expected to hold the index values for each column in the statement's intended database table containing the autogenerated-keys of interest. Otherwise columnIndexes is ignored.

        Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

        By default, ResultSets from the returned object will be ResultSet.TYPE_FORWARD_ONLY type with a ResultSet.CONCUR_READ_ONLY concurrency mode.

        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - the SQL statement.
        colIndexes - the indexes of the columns for which auto-generated keys should be made available.
        Returns:
        the PreparedStatement containing the supplied SQL statement.
        Throws:
        SQLException - if a problem occurs accessing the database.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  String[] columns)
                                           throws SQLException
        Description copied from interface: Connection
        Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array. If sql is an SQL INSERT statement, columnNames is expected to hold the names of each column in the statement's associated database table containing the autogenerated-keys of interest. Otherwise columnNames is ignored.

        Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. Alternatively, if the driver is not capable of handling precompiled statements, the statement will not reach the database server until it is executed. This will have a bearing on precisely when SQLException instances get raised.

        By default, ResultSets from the returned object will be ResultSet.TYPE_FORWARD_ONLY type with a ResultSet.CONCUR_READ_ONLY concurrency mode.

        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - the SQL statement.
        columns - the names of the columns for which auto-generated keys should be made available.
        Returns:
        the PreparedStatement containing the supplied SQL statement.
        Throws:
        SQLException - if a problem occurs accessing the database.
      • isValid

        public boolean isValid​(int timeout)
                        throws SQLException
        Description copied from interface: Connection
        Returns true if this connection is still open and valid, false otherwise.
        Specified by:
        isValid in interface Connection
        Parameters:
        timeout - number of seconds to wait for a response before giving up and returning false, 0 to wait forever
        Throws:
        SQLException - if timeout < 0
      • setClientInfo

        public void setClientInfo​(Properties prop)
                           throws SQLClientInfoException
        Description copied from interface: Connection
        Replaces all client info properties with the name/value pairs from properties. All existing properties are removed. If an exception is thrown, the resulting state of this connection's client info properties is undefined.
        Specified by:
        setClientInfo in interface Connection
        Throws:
        SQLClientInfoException - if this connection is closed, or there's a problem setting a property.
      • unwrap

        public <T> T unwrap​(Class<T> iface)
                     throws SQLException
        Description copied from interface: Wrapper
        Returns an object that implements the given interface. If the caller is not a wrapper, a SQLException will be thrown.
        Specified by:
        unwrap in interface Wrapper
        Parameters:
        iface - - the class that defines the interface
        Returns:
        - an object that implements the interface
        Throws:
        SQLException - - if there is no object implementing the specific interface
      • isWrapperFor

        public boolean isWrapperFor​(Class iface)
                             throws SQLException
        Description copied from interface: Wrapper
        If the caller is a wrapper of the class or implements the given interface, the methods return false and vice versa.
        Specified by:
        isWrapperFor in interface Wrapper
        Parameters:
        iface - - the class that defines the interface
        Returns:
        - true if the instance implements the interface
        Throws:
        SQLException - - when an error occurs when judges the object