Class SQLAnywhereAdapter

  • All Implemented Interfaces:
    DatastoreAdapter

    public class SQLAnywhereAdapter
    extends BaseDatastoreAdapter
    Provides methods for adapting SQL language elements to the SQL Anywhere database.
    • Field Detail

      • datastoreBuildVersion

        protected int datastoreBuildVersion
        SQL Anywhere uses a product version of "major.minor.revision.build"
      • driverBuildVersion

        protected int driverBuildVersion
      • usingjConnect

        protected boolean usingjConnect
    • Constructor Detail

      • SQLAnywhereAdapter

        public SQLAnywhereAdapter​(java.sql.DatabaseMetaData metadata)
        Constructor.
        Parameters:
        metadata - MetaData for the DB
    • Method Detail

      • getCreateDatabaseStatement

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

        public java.lang.String getDropDatabaseStatement​(java.lang.String catalogName,
                                                         java.lang.String schemaName)
        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:
        catalogName - Name of the catalog
        schemaName - Name of the schema
        Returns:
        The DDL statement
      • getCreateTableStatement

        public java.lang.String getCreateTableStatement​(TableImpl table,
                                                        Column[] columns,
                                                        java.util.Properties props,
                                                        IdentifierFactory factory)
        Returns the appropriate SQL to create the given table having the given columns. No column constraints or key definitions should be included. It should return something like:
         CREATE TABLE FOO ( BAR VARCHAR(30), BAZ INTEGER )
         
        Specified by:
        getCreateTableStatement in interface DatastoreAdapter
        Overrides:
        getCreateTableStatement in class BaseDatastoreAdapter
        Parameters:
        table - The table to create.
        columns - The columns of the table.
        props - Properties for controlling the table creation
        factory - Factory for identifiers
        Returns:
        The text of the SQL statement.
      • getDropTableStatement

        public java.lang.String getDropTableStatement​(Table table)
        Accessor for the DROP TABLE statement for SQL Anywhere SQL Anywhere doesn't support CASCADE so just return a simple 'DROP TABLE table-name'
        Specified by:
        getDropTableStatement in interface DatastoreAdapter
        Overrides:
        getDropTableStatement in class BaseDatastoreAdapter
        Parameters:
        table - The table to drop.
        Returns:
        The DROP TABLE statement
      • getUpdateTableStatement

        public SQLText getUpdateTableStatement​(SQLTable tbl,
                                               SQLText setSQL)
        Method to return the SQLText for an UPDATE TABLE statement. Returns the SQLText for UPDATE T1 SET x1 = val1, x2 = val2 FROM MYTBL T1. Override if the datastore doesn't support that standard syntax.
        Specified by:
        getUpdateTableStatement in interface DatastoreAdapter
        Overrides:
        getUpdateTableStatement in class BaseDatastoreAdapter
        Parameters:
        tbl - The primary table
        setSQL - The SQLText for the SET component
        Returns:
        SQLText for the update statement
      • 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
      • 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 - The Store Manager
        Returns:
        The keyword for a column using auto-increment
      • getSequenceCreateStmt

        public java.lang.String getSequenceCreateStmt​(java.lang.String sequence_name,
                                                      java.lang.Integer min,
                                                      java.lang.Integer max,
                                                      java.lang.Integer start,
                                                      java.lang.Integer increment,
                                                      java.lang.Integer cache_size)
        Accessor for the sequence statement to create the sequence.
        Specified by:
        getSequenceCreateStmt in interface DatastoreAdapter
        Overrides:
        getSequenceCreateStmt in class BaseDatastoreAdapter
        Parameters:
        sequence_name - 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
        cache_size - Cache size for the sequence
        Returns:
        The statement for getting the next id from the sequence
      • sequenceExists

        public boolean sequenceExists​(java.sql.Connection conn,
                                      java.lang.String catalogName,
                                      java.lang.String schemaName,
                                      java.lang.String seqName)
        Determine if a sequence exists
        Specified by:
        sequenceExists in interface DatastoreAdapter
        Overrides:
        sequenceExists in class BaseDatastoreAdapter
        Parameters:
        conn - Connection to database
        catalogName - Database catalog name
        schemaName - Database schema name
        seqName - Name of the sequence
        Returns:
        The statement for getting the next id for the sequence
      • getSequenceNextStmt

        public java.lang.String getSequenceNextStmt​(java.lang.String sequence_name)
        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:
        sequence_name - Name of the sequence
        Returns:
        The statement for getting the next id for the sequence
      • getRangeByLimitEndOfStatementClause

        public java.lang.String getRangeByLimitEndOfStatementClause​(long offset,
                                                                    long count,
                                                                    boolean hasOrdering)
        Method to return the SQL to append to the WHERE clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword.
        Specified by:
        getRangeByLimitEndOfStatementClause in interface DatastoreAdapter
        Overrides:
        getRangeByLimitEndOfStatementClause in class BaseDatastoreAdapter
        Parameters:
        offset - The offset to return from
        count - The number of items to return
        hasOrdering - Whether ordering is present
        Returns:
        The SQL to append to allow for ranges using LIMIT.
      • 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