Class ConnectionImpl

  • All Implemented Interfaces:
    ParsedStatement, java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper
    Direct Known Subclasses:
    JUnitConnectionImpl

    public class ConnectionImpl
    extends WrapperRelease<java.sql.Statement>
    implements java.sql.Connection, ParsedStatement
    Wrapper for the jdbc Connection class CAUTION: Please be aware that this file will be compiled by using jdk 1.6 and jdk 1.7,
    for being successful in both cases we have to suppress the generation of the @override annotation. So please DONT OPEN/SAVE this file by using eclipse !!!!
    • Constructor Detail

      • ConnectionImpl

        public ConnectionImpl​(HybrisDataSource dataSource,
                              java.sql.Connection connection)
    • Method Detail

      • gotError

        protected boolean gotError()
      • hasBeenRollbacked

        protected boolean hasBeenRollbacked()
      • notifyError

        protected void notifyError​(java.sql.SQLException cause)
      • logError

        protected void logError​(java.sql.SQLException e,
                                java.lang.String message)
      • getConnectionInfo

        protected java.lang.String getConnectionInfo()
      • protectReadOnly

        protected void protectReadOnly​(java.lang.String sql)
                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • assureWritable

        protected void assureWritable()
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • invalidate

        public void invalidate()
      • unsetTxBound

        public void unsetTxBound()
      • restoreAutoCommit

        protected void restoreAutoCommit()
      • restoreTxIsolationLevel

        protected void restoreTxIsolationLevel()
      • autoRollbackOnUnsetTxBOund

        protected void autoRollbackOnUnsetTxBOund()
      • setTxBoundNoUserTA

        public void setTxBoundNoUserTA()
      • setTxBoundUserTA

        public void setTxBoundUserTA​(java.lang.Integer isolationLevel)
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isTxBound

        public boolean isTxBound()
      • isTxBoundUserTA

        public boolean isTxBoundUserTA()
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in interface java.sql.Connection
      • prepareForUse

        public void prepareForUse()
      • restoreAfterUse

        public void restoreAfterUse()
                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • closeUnderlayingConnection

        public void closeUnderlayingConnection()
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getUnderlayingConnection

        public java.sql.Connection getUnderlayingConnection()
        returns the underlying physical java.sql.Connection
        Returns:
        the connection
      • getConnectionID

        public int getConnectionID()
        returns the connection ID which is a unique ID which is counted up after each creation of a new connection
        Returns:
        the connID
      • wrapPreparedStatement

        protected java.sql.PreparedStatement wrapPreparedStatement​(java.sql.PreparedStatement pstmt,
                                                                   java.lang.String sql)
        returns a wrapped PreparedStatement
      • isFlexibleSyntax

        protected boolean isFlexibleSyntax​(java.lang.String query)
                                    throws java.sql.SQLException
        logic for recognizing if 'query has' flexible search syntax if { or } happends to ba after from else in first 20 signs of the query - less reliable
        Specified by:
        isFlexibleSyntax in class WrapperRelease<java.sql.Statement>
        Throws:
        java.sql.SQLException
      • close

        public void close()
                   throws java.sql.SQLException
        if this connection is not TX bound, it is returned to the JDBC Connection pool If it is TX bound, we do nothing, because the next DataSourceImpl.getConnection() will return exactly this connection. It will then be closed if the connection is committed or rollbacked.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Throws:
        java.sql.SQLException - if the connection was already closed before
      • notifyStatementClosed

        protected void notifyStatementClosed​(StatementImpl stmt)
      • releaseResourceImpl

        protected void releaseResourceImpl​(java.sql.Statement resource)
                                    throws java.sql.SQLException
        Specified by:
        releaseResourceImpl in class WrapperRelease<java.sql.Statement>
        Parameters:
        resource - abstracts, release mechanism for underlying resource any specific implementation for release resources should add here
        Throws:
        java.sql.SQLException
      • parseQuery

        public java.lang.String parseQuery​(java.lang.String queryIn)
                                    throws java.sql.SQLException
        Specified by:
        parseQuery in interface ParsedStatement
        Parameters:
        queryIn - query to be parsed in flex-mode implementation
        Returns:
        parsed query into plain sql for underlying DB to perform on
        Throws:
        java.sql.SQLException - is thrown if during parsing something goes wrong
      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
                           throws java.sql.SQLException
        Specified by:
        setAutoCommit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getAutoCommit

        public boolean getAutoCommit()
                              throws java.sql.SQLException
        Specified by:
        getAutoCommit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • commit

        public void commit()
                    throws java.sql.SQLException
        Specified by:
        commit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • commitInternal

        protected void commitInternal()
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • rollback

        public void rollback()
                      throws java.sql.SQLException
        Specified by:
        rollback in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • rollbackInternal

        protected void rollbackInternal()
                                 throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • rollback

        public void rollback​(java.sql.Savepoint savePoint)
                      throws java.sql.SQLException
        Specified by:
        rollback in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStatement

        public java.sql.Statement createStatement()
                                           throws java.sql.SQLException
        Specified by:
        createStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency)
                                           throws java.sql.SQLException
        Specified by:
        createStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency,
                                                  int resultSetHoldability)
                                           throws java.sql.SQLException
        Specified by:
        createStatement 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 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 sql,
                                                           int autoGeneratedKeys)
                                                    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[] columnIndexes)
                                                    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,
                                                           java.lang.String[] columnNames)
                                                    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,
                                                           int resultSetHoldability)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • 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 sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency,
                                                      int resultSetHoldability)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getMetaData

        public java.sql.DatabaseMetaData getMetaData()
                                              throws java.sql.SQLException
        Specified by:
        getMetaData in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getCatalog

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

        public void setCatalog​(java.lang.String catalog)
                        throws java.sql.SQLException
        Specified by:
        setCatalog in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getHoldability

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

        public void setHoldability​(int holdability)
                            throws java.sql.SQLException
        Specified by:
        setHoldability in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getTransactionIsolation

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

        public void setTransactionIsolation​(int level)
                                     throws java.sql.SQLException
        Specified by:
        setTransactionIsolation in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getTypeMap

        public java.util.Map getTypeMap()
                                 throws java.sql.SQLException
        Specified by:
        getTypeMap in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getWarnings

        public java.sql.SQLWarning getWarnings()
                                        throws java.sql.SQLException
        Specified by:
        getWarnings in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • clearWarnings

        public void clearWarnings()
                           throws java.sql.SQLException
        Specified by:
        clearWarnings in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • isReadOnly

        public boolean isReadOnly()
                           throws java.sql.SQLException
        Specified by:
        isReadOnly in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
                         throws java.sql.SQLException
        Specified by:
        setReadOnly in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSavepoint

        public java.sql.Savepoint setSavepoint()
                                        throws java.sql.SQLException
        Specified by:
        setSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSavepoint

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

        public void releaseSavepoint​(java.sql.Savepoint savepoint)
                              throws java.sql.SQLException
        Specified by:
        releaseSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • nativeSQL

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

        public void setTypeMap​(java.util.Map<java.lang.String,​java.lang.Class<?>> arg0)
                        throws java.sql.SQLException
        Specified by:
        setTypeMap 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
      • 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
      • 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 arg0)
                                       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
      • isWrapperFor

        public boolean isWrapperFor​(java.lang.Class<?> arg0)
                             throws java.sql.SQLException
        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • createArrayOf

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

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

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

        public void setClientInfo​(java.lang.String arg0,
                                  java.lang.String arg1)
                           throws java.sql.SQLClientInfoException
        Specified by:
        setClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLClientInfoException
      • unwrap

        public <T> T unwrap​(java.lang.Class<T> arg0)
                     throws java.sql.SQLException
        Specified by:
        unwrap in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • resetError

        public void resetError()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setSchema

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

        public java.lang.String getSchema()
                                   throws java.sql.SQLException
        Specified by:
        getSchema in interface java.sql.Connection
        Throws:
        java.sql.SQLException
        Since:
        jdk 1.7
      • 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
        Since:
        jdk 1.7
      • 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
        Since:
        jdk 1.7
      • getNetworkTimeout

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