Class DB2Adapter

    • Field Detail

      • DB2_RESERVED_WORDS

        public static final java.lang.String DB2_RESERVED_WORDS
        A string containing the list of DB2 keywords This list is normally obtained dynamically from the driver using "DatabaseMetaData.getSQLKeywords()". Based on database DB2 version 7.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DB2Adapter

        public DB2Adapter​(java.sql.DatabaseMetaData metadata)
        Constructs a DB2 adapter based on the given JDBC metadata.
        Parameters:
        metadata - the database metadata.
    • Method Detail

      • initialiseTypes

        public void initialiseTypes​(org.datanucleus.store.schema.StoreSchemaHandler handler,
                                    org.datanucleus.store.connection.ManagedConnection mconn)
        Initialise the types for this datastore.
        Specified by:
        initialiseTypes in interface DatastoreAdapter
        Overrides:
        initialiseTypes in class BaseDatastoreAdapter
        Parameters:
        handler - SchemaHandler that we initialise the types for
        mconn - Managed connection to use
      • getSchemaName

        public java.lang.String getSchemaName​(java.sql.Connection conn)
                                       throws java.sql.SQLException
        Description copied from class: BaseDatastoreAdapter
        Accessor for the Schema Name for this datastore.
        Specified by:
        getSchemaName in interface DatastoreAdapter
        Overrides:
        getSchemaName in class BaseDatastoreAdapter
        Parameters:
        conn - Connection to the datastore
        Returns:
        The schema name
        Throws:
        java.sql.SQLException - Thrown if error occurs in determining the schema name.
      • newSQLTypeInfo

        public SQLTypeInfo newSQLTypeInfo​(java.sql.ResultSet rs)
        Description copied from interface: DatastoreAdapter
        Create a new SQL type info from the current row of the passed ResultSet. Allows an adapter to override particular types where the JDBC driver is known to be buggy.
        Specified by:
        newSQLTypeInfo in interface DatastoreAdapter
        Overrides:
        newSQLTypeInfo in class BaseDatastoreAdapter
        Parameters:
        rs - ResultSet
        Returns:
        The SQL type info
      • newRDBMSColumnInfo

        public RDBMSColumnInfo newRDBMSColumnInfo​(java.sql.ResultSet rs)
        Method to create a column info for the current row. Overrides the dataType/columnSize/decimalDigits to cater for DB2 particularities.
        Specified by:
        newRDBMSColumnInfo in interface DatastoreAdapter
        Overrides:
        newRDBMSColumnInfo in class BaseDatastoreAdapter
        Parameters:
        rs - ResultSet from DatabaseMetaData.getColumns()
        Returns:
        column info
      • getDropDatabaseStatement

        public java.lang.String getDropDatabaseStatement​(java.lang.String schemaName,
                                                         java.lang.String catalogName)
        Description copied from interface: DatastoreAdapter
        Method to return the statement necessary to drop a database with this RDBMS. Note that some RDBMS don't support this.
        Specified by:
        getDropDatabaseStatement in interface DatastoreAdapter
        Overrides:
        getDropDatabaseStatement in class BaseDatastoreAdapter
        Parameters:
        schemaName - Name of the catalog
        catalogName - Name of the schema
        Returns:
        The DDL statement
      • getContinuationString

        public java.lang.String getContinuationString()
        Continuation string to use where the SQL statement goes over more than 1 line. DB2 doesn't convert newlines into continuation characters and so we just provide a space so that it accepts the statement.
        Overrides:
        getContinuationString in class BaseDatastoreAdapter
        Returns:
        Continuation string.
      • getIdentityLastValueStmt

        public java.lang.String getIdentityLastValueStmt​(Table table,
                                                         java.lang.String columnName)
        Accessor for the auto-increment sql statement for this datastore.
        Specified by:
        getIdentityLastValueStmt in interface DatastoreAdapter
        Overrides:
        getIdentityLastValueStmt in class BaseDatastoreAdapter
        Parameters:
        table - Name of the table that the autoincrement is for
        columnName - Name of the column that the autoincrement is for
        Returns:
        The statement for getting the latest auto-increment key
      • getIdentityKeyword

        public java.lang.String getIdentityKeyword​(org.datanucleus.store.StoreManager storeMgr)
        Accessor for the auto-increment keyword for generating DDLs (CREATE TABLEs...).
        Specified by:
        getIdentityKeyword in interface DatastoreAdapter
        Overrides:
        getIdentityKeyword in class BaseDatastoreAdapter
        Parameters:
        storeMgr - Store Manager
        Returns:
        The keyword for a column using auto-increment
      • getSequenceCreateStmt

        public java.lang.String getSequenceCreateStmt​(java.lang.String sequenceName,
                                                      java.lang.Integer min,
                                                      java.lang.Integer max,
                                                      java.lang.Integer start,
                                                      java.lang.Integer increment,
                                                      java.lang.Integer cacheSize)
        Accessor for the sequence statement to create the sequence.
        Specified by:
        getSequenceCreateStmt in interface DatastoreAdapter
        Overrides:
        getSequenceCreateStmt in class BaseDatastoreAdapter
        Parameters:
        sequenceName - Name of the sequence
        min - Minimum value for the sequence
        max - Maximum value for the sequence
        start - Start value for the sequence
        increment - Increment value for the sequence
        cacheSize - Cache size for the sequence
        Returns:
        The statement for getting the next id from the sequence
      • getSequenceNextStmt

        public java.lang.String getSequenceNextStmt​(java.lang.String sequenceName)
        Accessor for the statement for getting the next id from the sequence for this datastore.
        Specified by:
        getSequenceNextStmt in interface DatastoreAdapter
        Overrides:
        getSequenceNextStmt in class BaseDatastoreAdapter
        Parameters:
        sequenceName - Name of the sequence
        Returns:
        The statement for getting the next id for the sequence
      • getSQLMethodClass

        public java.lang.Class<? extends SQLMethod> getSQLMethodClass​(java.lang.String className,
                                                                      java.lang.String methodName,
                                                                      org.datanucleus.ClassLoaderResolver clr)
        Description copied from interface: DatastoreAdapter
        Accessor for the SQLMethod class for the query invocation of specified class + method name (if available for this datastore).
        Specified by:
        getSQLMethodClass in interface DatastoreAdapter
        Overrides:
        getSQLMethodClass in class BaseDatastoreAdapter
        Parameters:
        className - Name of the class (or null if this is a STATIC method)
        methodName - Method name
        clr - ClassLoader resolver, in case className is a subclass of a supported type
        Returns:
        The SQLMethod class (or null if not defined for this datastore).
      • loadColumnMappings

        protected void loadColumnMappings​(org.datanucleus.plugin.PluginManager mgr,
                                          org.datanucleus.ClassLoaderResolver clr)
        Load all datastore mappings for this RDBMS database.
        Overrides:
        loadColumnMappings in class BaseDatastoreAdapter
        Parameters:
        mgr - the PluginManager
        clr - the ClassLoaderResolver