Interface AdempiereDatabase

  • All Known Implementing Classes:
    DB_Oracle, DB_PostgreSQL

    public interface AdempiereDatabase
    Interface for Adempiere Databases
    Version:
    $Id: AdempiereDatabase.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
    Author:
    Jorg Janke
    • Field Detail

      • LOCK_TIME_OUT

        static final int LOCK_TIME_OUT
        default lock timeout, 60 seconds
        See Also:
        Constant Field Values
      • CMD_CREATE_DATABASE

        static final int CMD_CREATE_DATABASE
        Create Database/Schema Commands
        See Also:
        Constant Field Values
      • CMD_DROP_DATABASE

        static final int CMD_DROP_DATABASE
        Drop Database/Schema Commands
        See Also:
        Constant Field Values
    • Method Detail

      • getName

        String getName()
        Get Database Name
        Returns:
        database short name
      • getDescription

        String getDescription()
        Get Database Description
        Returns:
        database long name and version
      • getStandardPort

        int getStandardPort()
        Get Standard JDBC Port
        Returns:
        standard port
      • getConnectionURL

        String getConnectionURL​(CConnection connection)
        Get Database Connection String
        Parameters:
        connection - Connection Descriptor
        Returns:
        connection String
      • getConnectionURL

        String getConnectionURL​(String dbHost,
                                int dbPort,
                                String dbName,
                                String userName)
        Get Connection URL
        Parameters:
        dbHost - db Host
        dbPort - db Port
        dbName - db Name
        userName - user name
        Returns:
        url
      • getConnectionURL

        String getConnectionURL​(String connectionURL,
                                String userName)
        Get Database Connection String
        Parameters:
        connectionURL - Connection URL
        userName - user name
        Returns:
        connection String
      • getCatalog

        String getCatalog()
        Get JDBC Catalog
        Returns:
        catalog
      • getSchema

        String getSchema()
        Get JDBC Schema
        Returns:
        schema
      • supportsBLOB

        boolean supportsBLOB()
        Supports BLOB
        Returns:
        true if BLOB is supported
      • toString

        String toString()
        String Representation
        Overrides:
        toString in class Object
        Returns:
        info
      • convertStatement

        String convertStatement​(String oraStatement)
        Convert an individual Oracle Style statements to target database statement syntax
        Parameters:
        oraStatement - oracle statement
        Returns:
        converted Statement
      • isSupported

        boolean isSupported​(String sql)
        Check if DBMS support the sql statement
        Returns:
        true: yes
      • getConstraintType

        String getConstraintType​(Connection conn,
                                 String tableName,
                                 String IXName)
        Get constraint type associated with the index
        Returns:
        String[0] = 0: do not know, 1: Primary Key 2: Foreign Key String[1] - String[n] = Constraint Name
      • getAlternativeSQL

        String getAlternativeSQL​(int reExNo,
                                 String msg,
                                 String sql)
        Check and generate an alternative SQL
        Returns:
        String, the alternative SQL, null if no alternative
      • getSystemUser

        String getSystemUser()
        Get Name of System User
        Returns:
        e.g. sa, system
      • getSystemDatabase

        String getSystemDatabase​(String databaseName)
        Get Name of System Database
        Parameters:
        databaseName - database Name
        Returns:
        e.g. master or database Name
      • TO_DATE

        String TO_DATE​(Timestamp time,
                       boolean dayOnly)
        Create SQL TO Date String from Timestamp
        Parameters:
        time - Date to be converted
        dayOnly - true if time set to 00:00:00
        Returns:
        date function
      • TO_CHAR

        String TO_CHAR​(String columnName,
                       int displayType,
                       String AD_Language)
        Create SQL for formatted Date, Number
        Parameters:
        columnName - the column name in the SQL
        displayType - Display Type
        AD_Language - 6 character language setting (from Env.LANG_*)
        Returns:
        TRIM(TO_CHAR(columnName,'999G999G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')) or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
        See Also:
        DisplayType, Env
      • TO_NUMBER

        String TO_NUMBER​(BigDecimal number,
                         int displayType)
        Return number as string for INSERT statements with correct precision
        Parameters:
        number - number
        displayType - display Type
        Returns:
        number as string
      • getNextID

        int getNextID​(String Name,
                      String trxName)
        Return next sequence this Sequence
        Parameters:
        Name - Sequence
        trxName - Transaction
      • getNextID

        int getNextID​(String Name)
        Return next sequence this Sequence
        Parameters:
        Name - Sequence
      • createSequence

        boolean createSequence​(String name,
                               int increment,
                               int minvalue,
                               int maxvalue,
                               int start,
                               String trxName)
      • getCommands

        String[] getCommands​(int cmdType)
        Get SQL Commands. The following variables are resolved:
        Parameters:
        cmdType - CMD_*
        Returns:
        array of commands to be executed
      • getCachedConnection

        Connection getCachedConnection​(CConnection connection,
                                       boolean autoCommit,
                                       int transactionIsolation)
                                throws Exception
        Get Cached Connection on Server
        Parameters:
        connection - info
        autoCommit - true if autocommit connection
        transactionIsolation - Connection transaction level
        Returns:
        connection or null
        Throws:
        Exception
      • getDataSource

        DataSource getDataSource​(CConnection connection)
        Create DataSource
        Parameters:
        connection - connection
        Returns:
        data dource
      • getStatus

        String getStatus()
        Get Status
        Returns:
        status info or null if no local datasource available
      • close

        void close()
        Close
      • isQueryTimeoutSupported

        boolean isQueryTimeoutSupported()
        Returns:
        true if jdbc driver support statement timeout
      • isPagingSupported

        boolean isPagingSupported()
        Is the database have sql extension that return a subset of the query result
        Returns:
        boolean
      • addPagingSQL

        String addPagingSQL​(String sql,
                            int start,
                            int end)
        modify sql to return a subset of the query result
        Parameters:
        sql -
        start -
        end -
        Returns:
      • forUpdate

        boolean forUpdate​(PO po,
                          int timeout)
        Lock PO for update
        Parameters:
        po -
        timeout -
        Returns:
        true if lock is granted
      • getNameOfUniqueConstraintError

        String getNameOfUniqueConstraintError​(Exception e)
      • subsetClauseForCSV

        String subsetClauseForCSV​(String columnName,
                                  String csv)
        Parameters:
        columnName -
        csv - comma separated value
        Returns:
        subset sql clause
      • intersectClauseForCSV

        String intersectClauseForCSV​(String columnName,
                                     String csv)
        Parameters:
        columnName -
        csv - comma separated value
        Returns:
        subset sql clause
      • quoteColumnName

        default String quoteColumnName​(String columnName)
        Quote column name if necessary (usually to avoid conflict with reserved keywords)
        Parameters:
        columnName -
        Returns:
        columnName or quoted columnName
      • isNativeMode

        default boolean isNativeMode()
        Returns:
        true if using native dialect, false if using oracle dialect
      • getNumericDataType

        String getNumericDataType()
        Returns:
        numeric data type name
      • getCharacterDataType

        String getCharacterDataType()
        Returns:
        fixed lenght character data type name
      • getVarcharDataType

        String getVarcharDataType()
        Returns:
        variable length character data type name
      • getVarcharLengthSuffix

        default String getVarcharLengthSuffix()
        Returns:
        variable length character data type suffix
      • getBlobDataType

        String getBlobDataType()
        Returns:
        binary large object data type name
      • getClobDataType

        String getClobDataType()
        Returns:
        character large object data type name
      • getTimestampDataType

        String getTimestampDataType()
        Returns:
        time stamp data type name
      • getSQLCreate

        default String getSQLCreate​(MTable table)
        Get SQL Create
        Parameters:
        table -
        Returns:
        create table DDL
      • getSQLDDL

        String getSQLDDL​(MColumn column)
        Parameters:
        column -
        Returns:
        ddl sql for column
      • getSQLAdd

        String getSQLAdd​(MTable table,
                         MColumn column)
        Parameters:
        table -
        column -
        Returns:
        add column sql
      • getSQLModify

        String getSQLModify​(MTable table,
                            MColumn column,
                            boolean setNullOption)
        Parameters:
        table -
        column -
        setNullOption -
        Returns:
        alter column sql
      • isQueryTimeout

        default boolean isQueryTimeout​(SQLException ex)
        Parameters:
        ex -
        Returns:
        true if ex is caused by query timeout