Class DBAdapter

    • Constructor Detail

      • DBAdapter

        public DBAdapter​(java.lang.String name,
                         java.lang.String version)
    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface IDBAdapter
      • getVersion

        public java.lang.String getVersion()
        Specified by:
        getVersion in interface IDBAdapter
      • getJDBCDriver

        @Deprecated
        public java.sql.Driver getJDBCDriver()
        Deprecated.
        As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).
        Specified by:
        getJDBCDriver in interface IDBAdapter
        Since:
        4.2
      • createJDBCDataSource

        @Deprecated
        public javax.sql.DataSource createJDBCDataSource()
        Deprecated.
        As of 4.2 no longer supported because of IP issues for external build dependencies (the vendor driver libs).
        Specified by:
        createJDBCDataSource in interface IDBAdapter
        Since:
        4.2
      • modifyConnection

        public java.sql.Connection modifyConnection​(java.sql.Connection connection)
        Specified by:
        modifyConnection in interface IDBAdapter
        Since:
        4.5
      • readSchema

        public IDBSchema readSchema​(java.sql.Connection connection,
                                    java.lang.String name)
        Specified by:
        readSchema in interface IDBAdapter
        Since:
        4.2
      • readSchema

        public void readSchema​(java.sql.Connection connection,
                               IDBSchema schema)
        Specified by:
        readSchema in interface IDBAdapter
        Since:
        4.2
      • readTables

        protected java.sql.ResultSet readTables​(java.sql.Connection connection,
                                                java.sql.DatabaseMetaData metaData,
                                                java.lang.String schemaName)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        4.3
      • readFields

        protected void readFields​(java.sql.Connection connection,
                                  IDBTable table)
                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        4.2
      • readIndices

        protected void readIndices​(java.sql.Connection connection,
                                   java.sql.DatabaseMetaData metaData,
                                   IDBTable table,
                                   java.lang.String schemaName)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        4.2
      • readIndices

        protected void readIndices​(java.sql.Connection connection,
                                   java.sql.ResultSet resultSet,
                                   IDBTable table,
                                   int indexNameColumn,
                                   int indexTypeColumn,
                                   int fieldNameColumn,
                                   int fieldPositionColumn)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        4.2
      • isPrimaryKeyShadow

        protected boolean isPrimaryKeyShadow​(java.sql.Connection connection,
                                             IDBTable table,
                                             java.lang.String name,
                                             IDBIndex.Type type,
                                             IDBField[] fields)
        Since:
        4.2
      • createTable

        protected void createTable​(java.sql.Connection connection,
                                   IDBTable table,
                                   IDBTableDelta delta)
        Since:
        4.2
      • dropTable

        protected void dropTable​(java.sql.Connection connection,
                                 IDBTable table,
                                 IDBTableDelta delta)
        Since:
        4.2
      • alterTable

        protected void alterTable​(java.sql.Connection connection,
                                  IDBTable table,
                                  IDBTableDelta delta)
        Since:
        4.2
      • createField

        protected void createField​(java.sql.Connection connection,
                                   java.lang.String tableName,
                                   IDBField field)
        Since:
        4.6
      • dropField

        protected void dropField​(java.sql.Connection connection,
                                 java.lang.String tableName,
                                 java.lang.String fieldName)
        Since:
        4.6
      • createIndex

        protected void createIndex​(java.sql.Connection connection,
                                   IDBIndex index,
                                   IDBIndexDelta delta)
        Since:
        4.2
      • createPrimaryKey

        protected void createPrimaryKey​(IDBIndex index,
                                        java.lang.StringBuilder builder)
        Since:
        4.2
      • createIndex

        protected void createIndex​(IDBIndex index,
                                   java.lang.StringBuilder builder)
        Since:
        4.2
      • createIndexFields

        protected void createIndexFields​(IDBIndex index,
                                         java.lang.StringBuilder builder)
        Since:
        4.2
      • dropIndex

        protected void dropIndex​(java.sql.Connection connection,
                                 IDBIndex index,
                                 IDBIndexDelta delta)
        Since:
        4.2
      • dropPrimaryKey

        protected void dropPrimaryKey​(IDBIndex index,
                                      java.lang.StringBuilder builder)
        Since:
        4.2
      • dropIndex

        protected void dropIndex​(IDBIndex index,
                                 java.lang.StringBuilder builder)
        Since:
        4.2
      • dropTable

        public boolean dropTable​(IDBTable table,
                                 java.sql.Statement statement)
        Specified by:
        dropTable in interface IDBAdapter
      • getDropTableSQL

        protected java.lang.String getDropTableSQL​(IDBTable table)
      • getFieldLength

        public int getFieldLength​(DBType type)
        Description copied from interface: IDBAdapter
        Returns the column length for the given database type.
        Specified by:
        getFieldLength in interface IDBAdapter
        Parameters:
        type - the DBType to check.
        Returns:
        the supported column length for the type.
        Since:
        4.2
      • toString

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

        public java.lang.String convertString​(java.sql.PreparedStatement preparedStatement,
                                              int parameterIndex,
                                              java.lang.String value)
        Since:
        4.3
      • convertString

        public java.lang.String convertString​(java.sql.ResultSet resultSet,
                                              int columnIndex,
                                              java.lang.String value)
        Since:
        4.3
      • convertString

        public java.lang.String convertString​(java.sql.ResultSet resultSet,
                                              java.lang.String columnLabel,
                                              java.lang.String value)
        Since:
        4.3
      • doCreateTable

        protected void doCreateTable​(IDBTable table,
                                     java.sql.Statement statement)
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        2.0
      • createIndex

        protected void createIndex​(IDBIndex index,
                                   java.sql.Statement statement,
                                   int num)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        2.0
      • addIndexField

        protected void addIndexField​(java.lang.StringBuilder builder,
                                     IDBField field)
      • createConstraints

        protected java.lang.String createConstraints​(IDBTable table)
        Since:
        2.0
      • createFieldDefinition

        protected java.lang.String createFieldDefinition​(IDBField field)
        Since:
        2.0
      • getTypeName

        protected java.lang.String getTypeName​(IDBField field)
      • getSQL92ReservedWords

        public java.lang.String[] getSQL92ReservedWords()
      • isReservedWord

        public boolean isReservedWord​(java.lang.String word)
        Specified by:
        isReservedWord in interface IDBAdapter
      • createFieldDefinitions

        protected java.lang.String[] createFieldDefinitions​(IDBTable table)
        Since:
        4.2
      • appendFieldNames

        public void appendFieldNames​(java.lang.Appendable appendable,
                                     IDBTable table)
      • appendFieldDefs

        protected void appendFieldDefs​(java.lang.Appendable appendable,
                                       IDBTable table,
                                       java.lang.String[] defs)
        Since:
        4.2
      • adaptType

        public DBType adaptType​(DBType type)
        Description copied from interface: IDBAdapter
        Provide a way for the DBAdapter to override unsupported DB types with replacements. The default implementation just returns the given type. Subclasses may override single types with replacements.
        Specified by:
        adaptType in interface IDBAdapter
        Since:
        3.0
      • isValidFirstChar

        public boolean isValidFirstChar​(char ch)
        Description copied from interface: IDBAdapter
        Check if a character is valid as first character. (e.g., underscores are forbidden as first character in Derby elements.
        Specified by:
        isValidFirstChar in interface IDBAdapter
        Since:
        4.0
      • isDuplicateKeyException

        public boolean isDuplicateKeyException​(java.sql.SQLException ex)
        Description copied from interface: IDBAdapter
        Check if an exception indicates a constraint violation (duplicate key)
        Specified by:
        isDuplicateKeyException in interface IDBAdapter
        Since:
        4.0
      • isTableNotFoundException

        public boolean isTableNotFoundException​(java.sql.SQLException ex)
        Specified by:
        isTableNotFoundException in interface IDBAdapter
        Since:
        4.2
      • isColumnNotFoundException

        public boolean isColumnNotFoundException​(java.sql.SQLException ex)
        Specified by:
        isColumnNotFoundException in interface IDBAdapter
        Since:
        4.2
      • sqlRenameField

        public java.lang.String sqlRenameField​(IDBField field,
                                               java.lang.String oldName)
        Specified by:
        sqlRenameField in interface IDBAdapter
        Since:
        4.2
      • sqlModifyField

        protected java.lang.String sqlModifyField​(java.lang.String tableName,
                                                  java.lang.String fieldName,
                                                  java.lang.String definition)
        Since:
        4.2
      • format

        public java.lang.String format​(java.sql.PreparedStatement stmt)
        Since:
        4.2
      • format

        public java.lang.String format​(java.sql.ResultSet resultSet)
        Since:
        4.2
      • convertToSQL

        public java.lang.Object convertToSQL​(java.lang.Object value)
        Since:
        4.9
      • getDefaultDBLength

        public static int getDefaultDBLength​(DBType type)
        Since:
        4.2
      • generateReservedWords

        protected static void generateReservedWords​(java.sql.Connection connection,
                                                    java.lang.String[] words)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        Since:
        4.9