Class JDOConnectionJDBCImpl

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper, javax.jdo.datastore.JDOConnection

    public class JDOConnectionJDBCImpl
    extends JDOConnectionImpl
    implements java.sql.Connection
    Implementation of a JDO connection that is also a wrapper for "java.sql.Connection".
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.sql.Connection conn
      The JDBC connection (shortcut for the native connection of the NucleusConnection).
      private boolean isAvailable
      whether this connection is available to the developer
      • Fields inherited from interface java.sql.Connection

        TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
    • Constructor Summary

      Constructors 
      Constructor Description
      JDOConnectionJDBCImpl​(org.datanucleus.store.NucleusConnection nconn)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort​(java.util.concurrent.Executor executor)  
      void assertAvailable()
      Assert the JDOConnection is available.
      void clearWarnings()
      Method to clear warnings from the connection.
      void commit()
      Method to commit the connection.
      java.sql.Array createArrayOf​(java.lang.String typeName, java.lang.Object[] elements)  
      java.sql.Blob createBlob()  
      java.sql.Clob createClob()  
      java.sql.NClob createNClob()  
      java.sql.SQLXML createSQLXML()  
      java.sql.Statement createStatement()
      Accessor for a statement.
      java.sql.Statement createStatement​(int resultSetType, int resultSetConcurrency)
      Accessor for a statement.
      java.sql.Statement createStatement​(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
      Accessor for a statement.
      java.sql.Struct createStruct​(java.lang.String typeName, java.lang.Object[] attributes)  
      boolean getAutoCommit()
      Accessor for the autocommit setting.
      java.lang.String getCatalog()
      Accessor for the catalog.
      java.util.Properties getClientInfo()  
      java.lang.String getClientInfo​(java.lang.String name)  
      int getHoldability()
      Access the holdability of the connection.
      java.sql.DatabaseMetaData getMetaData()
      Accessor for the database metadata.
      int getNetworkTimeout()  
      java.lang.String getSchema()  
      int getTransactionIsolation()
      Accessor for the transaction isolation level.
      java.util.Map<java.lang.String,​java.lang.Class<?>> getTypeMap()
      Accessor for the type map.
      java.sql.SQLWarning getWarnings()
      Accessor for the warnings.
      boolean isAvailable()  
      boolean isClosed()
      Accessor for whether the connection is closed.
      boolean isReadOnly()
      Accessor for whether the connection is read only.
      boolean isValid​(int timeout)  
      boolean isWrapperFor​(java.lang.Class iface)  
      java.lang.String nativeSQL​(java.lang.String sql)
      Accessor for using native SQL.
      java.sql.CallableStatement prepareCall​(java.lang.String sql)  
      java.sql.CallableStatement prepareCall​(java.lang.String sql, int resultSetType, int resultSetConcurrency)  
      java.sql.CallableStatement prepareCall​(java.lang.String arg0, int arg1, int arg2, int arg3)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String sql)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String arg0, int arg1)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String arg0, int[] arg1)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String sql, int resultSetType, int resultSetConcurrency)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String arg0, int arg1, int arg2, int arg3)  
      java.sql.PreparedStatement prepareStatement​(java.lang.String arg0, java.lang.String[] arg1)  
      void releaseSavepoint​(java.sql.Savepoint pt)
      Mutator to release the savepoint.
      void rollback()
      Method to rollback the connection.
      void rollback​(java.sql.Savepoint pt)
      Mutator to rollback the savepoint.
      void setAutoCommit​(boolean autoCommit)
      Method to set the autocommit for the connection.
      void setCatalog​(java.lang.String catalog)
      Mutator for the catalog
      void setClientInfo​(java.lang.String name, java.lang.String value)  
      void setClientInfo​(java.util.Properties properties)  
      void setHoldability​(int holdability)
      Method to set the holdability for the connection.
      void setNetworkTimeout​(java.util.concurrent.Executor executor, int milliseconds)  
      void setReadOnly​(boolean readOnly)
      Method to set the read-only nature for the connection.
      java.sql.Savepoint setSavepoint()
      Mutator to set the savepoint.
      java.sql.Savepoint setSavepoint​(java.lang.String arg0)  
      void setSchema​(java.lang.String schema)  
      void setTransactionIsolation​(int level)
      Method to set the transaction isolation for the connection.
      void setTypeMap​(java.util.Map map)
      Method to set the type map
      <T> T unwrap​(java.lang.Class<T> iface)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.sql.Connection

        beginRequest, close, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
    • Field Detail

      • conn

        private final java.sql.Connection conn
        The JDBC connection (shortcut for the native connection of the NucleusConnection).
      • isAvailable

        private boolean isAvailable
        whether this connection is available to the developer
    • Constructor Detail

      • JDOConnectionJDBCImpl

        public JDOConnectionJDBCImpl​(org.datanucleus.store.NucleusConnection nconn)
        Constructor.
        Parameters:
        nconn - The Nucleus Connection delegate
    • Method Detail

      • isAvailable

        public boolean isAvailable()
      • getHoldability

        public int getHoldability()
                           throws java.sql.SQLException
        Access the holdability of the connection.
        Specified by:
        getHoldability in interface java.sql.Connection
        Returns:
        The holdability
        Throws:
        java.sql.SQLException - if there is a problem
      • getTransactionIsolation

        public int getTransactionIsolation()
                                    throws java.sql.SQLException
        Accessor for the transaction isolation level.
        Specified by:
        getTransactionIsolation in interface java.sql.Connection
        Returns:
        The isolation level
        Throws:
        java.sql.SQLException - if there is a problem
      • clearWarnings

        public void clearWarnings()
                           throws java.sql.SQLException
        Method to clear warnings from the connection.
        Specified by:
        clearWarnings in interface java.sql.Connection
        Throws:
        java.sql.SQLException - thrown if there is a problem
      • commit

        public void commit()
                    throws java.sql.SQLException
        Method to commit the connection.
        Specified by:
        commit in interface java.sql.Connection
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • rollback

        public void rollback()
                      throws java.sql.SQLException
        Method to rollback the connection.
        Specified by:
        rollback in interface java.sql.Connection
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • getAutoCommit

        public boolean getAutoCommit()
                              throws java.sql.SQLException
        Accessor for the autocommit setting.
        Specified by:
        getAutoCommit in interface java.sql.Connection
        Returns:
        Whether to autocommit
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • isClosed

        public boolean isClosed()
                         throws java.sql.SQLException
        Accessor for whether the connection is closed.
        Specified by:
        isClosed in interface java.sql.Connection
        Returns:
        Whether it is closed.
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • isReadOnly

        public boolean isReadOnly()
                           throws java.sql.SQLException
        Accessor for whether the connection is read only.
        Specified by:
        isReadOnly in interface java.sql.Connection
        Returns:
        Whether it is read only.
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • setHoldability

        public void setHoldability​(int holdability)
                            throws java.sql.SQLException
        Method to set the holdability for the connection.
        Specified by:
        setHoldability in interface java.sql.Connection
        Parameters:
        holdability - The holdability
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • setTransactionIsolation

        public void setTransactionIsolation​(int level)
                                     throws java.sql.SQLException
        Method to set the transaction isolation for the connection.
        Specified by:
        setTransactionIsolation in interface java.sql.Connection
        Parameters:
        level - The transaction isolation
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
                           throws java.sql.SQLException
        Method to set the autocommit for the connection.
        Specified by:
        setAutoCommit in interface java.sql.Connection
        Parameters:
        autoCommit - Whether to autocommit
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
                         throws java.sql.SQLException
        Method to set the read-only nature for the connection.
        Specified by:
        setReadOnly in interface java.sql.Connection
        Parameters:
        readOnly - whether it is read-only
        Throws:
        java.sql.SQLException - thrown if an error occurs.
      • getCatalog

        public java.lang.String getCatalog()
                                    throws java.sql.SQLException
        Accessor for the catalog.
        Specified by:
        getCatalog in interface java.sql.Connection
        Returns:
        The catalog
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • setCatalog

        public void setCatalog​(java.lang.String catalog)
                        throws java.sql.SQLException
        Mutator for the catalog
        Specified by:
        setCatalog in interface java.sql.Connection
        Parameters:
        catalog - The catalog
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • getMetaData

        public java.sql.DatabaseMetaData getMetaData()
                                              throws java.sql.SQLException
        Accessor for the database metadata.
        Specified by:
        getMetaData in interface java.sql.Connection
        Returns:
        The database metadata
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • getWarnings

        public java.sql.SQLWarning getWarnings()
                                        throws java.sql.SQLException
        Accessor for the warnings.
        Specified by:
        getWarnings in interface java.sql.Connection
        Returns:
        The warnings
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • setSavepoint

        public java.sql.Savepoint setSavepoint()
                                        throws java.sql.SQLException
        Mutator to set the savepoint.
        Specified by:
        setSavepoint in interface java.sql.Connection
        Returns:
        The savepoint
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • releaseSavepoint

        public void releaseSavepoint​(java.sql.Savepoint pt)
                              throws java.sql.SQLException
        Mutator to release the savepoint.
        Specified by:
        releaseSavepoint in interface java.sql.Connection
        Parameters:
        pt - The savepoint
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • rollback

        public void rollback​(java.sql.Savepoint pt)
                      throws java.sql.SQLException
        Mutator to rollback the savepoint.
        Specified by:
        rollback in interface java.sql.Connection
        Parameters:
        pt - The savepoint
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • createStatement

        public java.sql.Statement createStatement()
                                           throws java.sql.SQLException
        Accessor for a statement.
        Specified by:
        createStatement in interface java.sql.Connection
        Returns:
        The statement
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency)
                                           throws java.sql.SQLException
        Accessor for a statement.
        Specified by:
        createStatement in interface java.sql.Connection
        Parameters:
        resultSetType - type of results
        resultSetConcurrency - The concurrency
        Returns:
        The statement
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency,
                                                  int resultSetHoldability)
                                           throws java.sql.SQLException
        Accessor for a statement.
        Specified by:
        createStatement in interface java.sql.Connection
        Parameters:
        resultSetType - type of results
        resultSetConcurrency - The concurrency
        resultSetHoldability - The holdability
        Returns:
        The statement
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • getTypeMap

        public java.util.Map<java.lang.String,​java.lang.Class<?>> getTypeMap()
                                                                            throws java.sql.SQLException
        Accessor for the type map.
        Specified by:
        getTypeMap in interface java.sql.Connection
        Returns:
        The type map
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • setTypeMap

        public void setTypeMap​(java.util.Map map)
                        throws java.sql.SQLException
        Method to set the type map
        Specified by:
        setTypeMap in interface java.sql.Connection
        Parameters:
        map - The type map
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • nativeSQL

        public java.lang.String nativeSQL​(java.lang.String sql)
                                   throws java.sql.SQLException
        Accessor for using native SQL.
        Specified by:
        nativeSQL in interface java.sql.Connection
        Parameters:
        sql - The sql
        Returns:
        The native SQL
        Throws:
        java.sql.SQLException - Thrown if an error occurs
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String arg0,
                                                      int arg1,
                                                      int arg2,
                                                      int arg3)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String arg0,
                                                           int arg1)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String arg0,
                                                           int arg1,
                                                           int arg2,
                                                           int arg3)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String arg0,
                                                           int[] arg1)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSavepoint

        public java.sql.Savepoint setSavepoint​(java.lang.String arg0)
                                        throws java.sql.SQLException
        Specified by:
        setSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String arg0,
                                                           java.lang.String[] arg1)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • assertAvailable

        public void assertAvailable()
        Assert the JDOConnection is available. Throws a JDOException if not available
      • createArrayOf

        public java.sql.Array createArrayOf​(java.lang.String typeName,
                                            java.lang.Object[] elements)
                                     throws java.sql.SQLException
        Specified by:
        createArrayOf in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createBlob

        public java.sql.Blob createBlob()
                                 throws java.sql.SQLException
        Specified by:
        createBlob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createClob

        public java.sql.Clob createClob()
                                 throws java.sql.SQLException
        Specified by:
        createClob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStruct

        public java.sql.Struct createStruct​(java.lang.String typeName,
                                            java.lang.Object[] attributes)
                                     throws java.sql.SQLException
        Specified by:
        createStruct in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getClientInfo

        public java.util.Properties getClientInfo()
                                           throws java.sql.SQLException
        Specified by:
        getClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getClientInfo

        public java.lang.String getClientInfo​(java.lang.String name)
                                       throws java.sql.SQLException
        Specified by:
        getClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • isValid

        public boolean isValid​(int timeout)
                        throws java.sql.SQLException
        Specified by:
        isValid in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setClientInfo

        public void setClientInfo​(java.util.Properties properties)
                           throws java.sql.SQLClientInfoException
        Specified by:
        setClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLClientInfoException
      • setClientInfo

        public void setClientInfo​(java.lang.String name,
                                  java.lang.String value)
                           throws java.sql.SQLClientInfoException
        Specified by:
        setClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLClientInfoException
      • createNClob

        public java.sql.NClob createNClob()
                                   throws java.sql.SQLException
        Specified by:
        createNClob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createSQLXML

        public java.sql.SQLXML createSQLXML()
                                     throws java.sql.SQLException
        Specified by:
        createSQLXML in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • 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
      • setSchema

        public void setSchema​(java.lang.String schema)
                       throws java.sql.SQLException
        Specified by:
        setSchema in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getSchema

        public java.lang.String getSchema()
                                   throws java.sql.SQLException
        Specified by:
        getSchema in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • abort

        public void abort​(java.util.concurrent.Executor executor)
                   throws java.sql.SQLException
        Specified by:
        abort in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setNetworkTimeout

        public void setNetworkTimeout​(java.util.concurrent.Executor executor,
                                      int milliseconds)
                               throws java.sql.SQLException
        Specified by:
        setNetworkTimeout in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getNetworkTimeout

        public int getNetworkTimeout()
                              throws java.sql.SQLException
        Specified by:
        getNetworkTimeout in interface java.sql.Connection
        Throws:
        java.sql.SQLException