Package tilda.db

Class Connection


  • public final class Connection
    extends java.lang.Object
    • Field Detail

      • _PoolId

        protected java.lang.String _PoolId
      • _PoolName

        protected java.lang.String _PoolName
      • _C

        protected java.sql.Connection _C
      • _Url

        protected java.lang.String _Url
    • Constructor Detail

      • Connection

        public Connection​(java.sql.Connection C)
                   throws java.lang.Exception,
                          java.sql.SQLException
        Throws:
        java.lang.Exception
        java.sql.SQLException
      • Connection

        public Connection​(java.sql.Connection C,
                          java.lang.String PoolId)
                   throws java.lang.Exception,
                          java.sql.SQLException
        Throws:
        java.lang.Exception
        java.sql.SQLException
    • Method Detail

      • unwrap

        public <T> T unwrap​(java.lang.Class<T> clas)
                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getPoolId

        public final java.lang.String getPoolId()
      • getPoolName

        public final java.lang.String getPoolName()
      • getURL

        public final java.lang.String getURL()
      • getDatabaseProductName

        public final java.lang.String getDatabaseProductName()
                                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getDatabaseProductVersion

        public final java.lang.String getDatabaseProductVersion()
                                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getDBTypeName

        public final java.lang.String getDBTypeName()
      • commit

        public final void commit()
                          throws java.sql.SQLException
        Wrapper to Connection.commit() with extra logging and performance tracking
        Throws:
        java.sql.SQLException
      • commitNoThrow

        public final java.sql.SQLException commitNoThrow()
        Wrapper to Connection.commit() with extra logging and performance tracking, but returns the exception, if any, instead of throwing. This should be typically used in a catch block when managing exceptions.
        Returns:
        an SQLException (instead of throwing) if one happens.
      • rollback

        public final void rollback()
                            throws java.sql.SQLException
        Wrapper to Connection.rollback() with extra logging and performance tracking
        Throws:
        java.sql.SQLException
      • rollbackNoThrow

        public final java.sql.SQLException rollbackNoThrow()
        Wrapper to Connection.rollback() with extra logging and performance tracking, but returns the exception, if any, instead of throwing. This should be typically used in a catch block when managing exceptions.
        Returns:
        an SQLException (instead of throwing) if one happens.
      • commitRollbackConnection

        public final void commitRollbackConnection​(boolean Commit)
                                            throws java.sql.SQLException
        Wrapper to commit() or rollback() based on parameter
        Parameters:
        Commit - true if commit is needed, or false if rollback
        Throws:
        java.sql.SQLException
      • commitRollbackConnectionNoThrow

        public final java.sql.SQLException commitRollbackConnectionNoThrow​(boolean Commit)
        Wrapper to commitNoThrow() or rollbackNoThrow() based on parameter. This should be typically used in a catch block when managing exceptions.
        Parameters:
        Commit - true if commit is needed, or false if rollback
        Returns:
        an SQLException (instead of throwing) if one happens.
      • close

        public final void close()
                         throws java.sql.SQLException
        Wrapper to Connection.close() with extra logging and performance tracking
        Throws:
        java.sql.SQLException
      • closeNoThrow

        public final java.sql.SQLException closeNoThrow()
        Wrapper to Connection.close() with extra logging and performance tracking, but returns the exception, if any, instead of throwing. This should be typically used in a catch block when managing exceptions.
        Returns:
        an SQLException (instead of throwing) if one happens.
      • createStatement

        public final java.sql.Statement createStatement()
                                                 throws java.sql.SQLException
        Straight wrapper to Connection.createStatement()
        Returns:
        Throws:
        java.sql.SQLException
      • getIsolation

        public java.lang.String getIsolation()
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String Q)
                                                    throws java.sql.SQLException
        Straight wrapper to Connection.prepareStatement(String)
        Returns:
        Throws:
        java.sql.SQLException
      • getCurrentTimestampStr

        public java.lang.String getCurrentTimestampStr()
                                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getCurrentDateStr

        public java.lang.String getCurrentDateStr()
                                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isErrNoData

        public boolean isErrNoData​(java.lang.Throwable T)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isLockOrConnectionError

        public boolean isLockOrConnectionError​(java.lang.Throwable T)
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isCanceledError

        public boolean isCanceledError​(java.lang.Throwable T)
                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeSelect

        public int executeSelect​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query,
                                 RecordProcessor RP)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeSelect

        public int executeSelect​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query,
                                 RecordProcessor RP,
                                 int Start,
                                 boolean Offsetted,
                                 int Size,
                                 boolean Limited)
                          throws java.lang.Exception
        Executes a query with a record processor, starting at Start (0 is beginning), and for Size records.
        Throws:
        java.lang.Exception
      • executeSelect

        public int executeSelect​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query,
                                 RecordProcessor RP,
                                 int Start,
                                 boolean Offsetted,
                                 int Size,
                                 boolean Limited,
                                 boolean CountAll)
                          throws java.lang.Exception
        Executes a query with a record processor, starting at Start (0 is beginning), and for Size records.
        Throws:
        java.lang.Exception
      • executeSelectLong

        public java.lang.Long executeSelectLong​(java.lang.String SchemaName,
                                                java.lang.String TableName,
                                                java.lang.String Query)
                                         throws java.lang.Exception
        Executes a query expecting a single result of any integer, up to a Long.
        Throws:
        java.lang.Exception
      • executeSelectString

        public java.lang.String executeSelectString​(java.lang.String SchemaName,
                                                    java.lang.String TableName,
                                                    java.lang.String Query)
                                             throws java.lang.Exception
        Executes a query expecting a single result of of a string.
        Throws:
        java.lang.Exception
      • executeMetaFullSelect

        public int executeMetaFullSelect​(java.lang.String schemaName,
                                         java.lang.String tableViewName,
                                         RecordProcessor RP)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeMetaFullSelect

        public int executeMetaFullSelect​(TableViewMeta tvm,
                                         RecordProcessor RP)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeUpdate

        public int executeUpdate​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeInsert

        public int executeInsert​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeDelete

        public int executeDelete​(java.lang.String SchemaName,
                                 java.lang.String TableName,
                                 java.lang.String Query)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeDDL

        public boolean executeDDL​(java.lang.String SchemaName,
                                  java.lang.String TableName,
                                  java.lang.String Query)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createArrayOf

        public java.sql.Array createArrayOf​(java.lang.String TypeName,
                                            java.lang.Object[] A)
                                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setSavepoint

        public void setSavepoint()
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • releaseSavepoint

        public void releaseSavepoint​(boolean commit)
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getSQlCodeGen

        public CodeGenSql getSQlCodeGen()
      • getMetaData

        public java.sql.DatabaseMetaData getMetaData()
                                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • alterTableAddColumn

        public boolean alterTableAddColumn​(Column Col,
                                           java.lang.String DefaultValue,
                                           java.lang.String temporaryDefaultValue)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableDropColumn

        public boolean alterTableDropColumn​(Object Obj,
                                            java.lang.String ColumnName)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnNull

        public boolean alterTableAlterColumnNull​(Column Col,
                                                 java.lang.String DefaultValue)
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createTable

        public boolean createTable​(Object Obj)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createKeysEntry

        public boolean createKeysEntry​(Object Obj)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • dropView

        public boolean dropView​(View V)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • dropView

        public boolean dropView​(ViewMeta V,
                                boolean cascade)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createView

        public boolean createView​(View V)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createSchema

        public boolean createSchema​(Schema S)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAggregateStr

        public java.lang.String getAggregateStr​(AggregateType Agg)
      • supportsSelectLimit

        public boolean supportsSelectLimit()
      • supportsSelectOffset

        public boolean supportsSelectOffset()
      • getSelectLimitClause

        public java.lang.String getSelectLimitClause​(int Start,
                                                     int Size)
      • supportsSuperMetaDataQueries

        public boolean supportsSuperMetaDataQueries()
      • supportsReorg

        public boolean supportsReorg()
      • isCaseSentitiveSchemaTableViewNames

        public boolean isCaseSentitiveSchemaTableViewNames()
      • getDBStringType

        public DBStringType getDBStringType​(int Size)
        For String Columns, checks is the Database would type as a CHARACTER, VARCHAR, or TEXT (or whatever the equivalents are across different databases).
        Parameters:
        Size -
        Returns:
      • alterTableAlterColumnNumericSize

        public boolean alterTableAlterColumnNumericSize​(ColumnMeta ColMeta,
                                                        Column Col)
                                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnStringSize

        public boolean alterTableAlterColumnStringSize​(ColumnMeta ColMeta,
                                                       Column Col)
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnType

        public boolean alterTableAlterColumnType​(Connection Con,
                                                 ColumnMeta ColMeta,
                                                 Column Col,
                                                 ZoneInfo_Data defaultZI)
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnMulti

        public boolean alterTableAlterColumnMulti​(java.util.List<ColMetaColPair> BatchTypeCols,
                                                  java.util.List<ColMetaColPair> BatchSizeCols,
                                                  ZoneInfo_Data defaultZI)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getHelperFunctionsScript

        public java.lang.String getHelperFunctionsScript​(boolean Start)
                                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAclRolesScript

        public java.lang.String getAclRolesScript​(java.util.List<Schema> TildaList)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getTypeMapping

        public StringStringPair getTypeMapping​(int Type,
                                               java.lang.String Name,
                                               int Size,
                                               java.lang.String TypeName)
                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • supportsArrays

        public boolean supportsArrays()
      • getEqualCurrentTimestamp

        public java.lang.Object getEqualCurrentTimestamp()
      • getCommaCurrentTimestamp

        public java.lang.Object getCommaCurrentTimestamp()
      • getEqualCurrentDateTime

        public java.lang.Object getEqualCurrentDateTime()
      • getCommaCurrentDateTime

        public java.lang.Object getCommaCurrentDateTime()
      • getShortColumnVar

        public java.lang.String getShortColumnVar​(java.lang.String ColumnName)
      • getFullColumnVar

        public void getFullColumnVar​(java.lang.StringBuilder Str,
                                     java.lang.String SchemaName,
                                     java.lang.String TableName,
                                     java.lang.String ColumnName)
      • getFullColumnVarList

        public void getFullColumnVarList​(java.lang.StringBuilder str,
                                         ColumnDefinition[] cols)
      • getColumnType

        public void getColumnType​(java.lang.StringBuilder Str,
                                  ColumnType T,
                                  java.lang.Integer S,
                                  ColumnMode M,
                                  boolean Collection,
                                  java.lang.Integer Precision,
                                  java.lang.Integer Scale)
      • getFullTableVar

        public void getFullTableVar​(java.lang.StringBuilder Str,
                                    java.lang.String SchemaName,
                                    java.lang.String TableName)
      • setArray

        public void setArray​(java.sql.PreparedStatement PS,
                             int i,
                             ColumnType Type,
                             java.util.List<java.sql.Array> allocatedArrays,
                             java.lang.String[] val)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setArray

        public void setArray​(java.sql.PreparedStatement PS,
                             int i,
                             ColumnType Type,
                             java.util.List<java.sql.Array> allocatedArrays,
                             long[] val)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setArray

        public void setArray​(java.sql.PreparedStatement PS,
                             int i,
                             ColumnType Type,
                             java.util.List<java.sql.Array> allocatedArrays,
                             char[] val)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setArray

        public void setArray​(java.sql.PreparedStatement PS,
                             int i,
                             ColumnType Type,
                             java.util.List<java.sql.Array> allocatedArrays,
                             java.util.Collection<?> val)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getJsonParametrizedQueryPlaceHolder

        public java.lang.String getJsonParametrizedQueryPlaceHolder()
      • setOrderByWithNullsOrdering

        public void setOrderByWithNullsOrdering​(java.lang.StringBuilder Str,
                                                ColumnDefinition Col,
                                                boolean Asc,
                                                boolean NullsLast)
      • truncateTable

        public void truncateTable​(java.lang.String SchemaName,
                                  java.lang.String TableName,
                                  boolean cascade)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableComment

        public boolean alterTableComment​(Object Obj)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnComment

        public boolean alterTableAlterColumnComment​(Column Col)
                                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • handleCatch

        public boolean handleCatch​(java.sql.SQLException E,
                                   java.lang.String OperationDebugStr)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • alterTableReplaceTablePK

        public boolean alterTableReplaceTablePK​(Object Obj,
                                                PKMeta OldPK)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableDropFK

        public boolean alterTableDropFK​(Object Obj,
                                        FKMeta FK)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAddFK

        public boolean alterTableAddFK​(ForeignKey FK)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableDropIndex

        public boolean alterTableDropIndex​(Object Obj,
                                           IndexMeta IX)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableIndexDropCluster

        public boolean alterTableIndexDropCluster​(IndexMeta IX)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAddIndex

        public boolean alterTableAddIndex​(Index IX)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableIndexAddCluster

        public boolean alterTableIndexAddCluster​(Index IX)
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableRenameIndex

        public boolean alterTableRenameIndex​(Object Obj,
                                             java.lang.String OldName,
                                             java.lang.String NewName)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isSuperUser

        public boolean isSuperUser()
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • alterTableAlterColumnDefault

        public boolean alterTableAlterColumnDefault​(Column Col)
                                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getBackendId

        public java.lang.String getBackendId()
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • cancel

        public void cancel()
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAutoCommit

        public boolean getAutoCommit()
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setAutoCommit

        public void setAutoCommit​(boolean val)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • closeAll

        public static int closeAll​(java.util.List<Connection> CL)
                            throws java.lang.Exception
        Parameters:
        CL -
        Returns:
        Throws:
        java.lang.Exception
      • commitAll

        public static void commitAll​(java.util.List<Connection> CL)
                              throws java.sql.SQLException
        Commits all the connections in the list. This is doing a straightforward commit and not a fancier 2-phase coordinated commit of all connections.
        Parameters:
        CL -
        Throws:
        java.sql.SQLException - If one commit fails, the exception is thrown, and remaining connections are left untouched.
      • rollbackAll

        public static void rollbackAll​(java.util.List<Connection> CL)
                                throws java.sql.SQLException
        Rollbacks all the connections in the list. This is doing a straightforward rollback and not a fancier 2-phase coordinated rollback of all connections.
        Parameters:
        CL -
        Throws:
        java.sql.SQLException - If one rollback fails, the exception is thrown, and remaining connections are left untouched.
      • moveTableView

        public boolean moveTableView​(Base base,
                                     java.lang.String oldSchemaName)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • renameTableView

        public boolean renameTableView​(Base base,
                                       java.lang.String oldName)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • renameTableColumn

        public boolean renameTableColumn​(Column col,
                                         java.lang.String oldName)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getCurrentTimestamp

        public java.time.ZonedDateTime getCurrentTimestamp()
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getCurrentDate

        public java.time.LocalDate getCurrentDate()
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • reorgTable

        public boolean reorgTable​(java.lang.String schemaName,
                                  java.lang.String tableName,
                                  java.lang.String clusterIndexName,
                                  boolean verbose,
                                  boolean full)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception