Interface DBMSHandler

All Known Implementing Classes:
DBMSHandlerBase, DBMSHandlerDerby, DBMSHandlerH2, DBMSHandlerHSql, DBMSHandlerMSSQL, DBMSHandlerMySQL, DBMSHandlerOracle, DBMSHandlerPostgreSQL, DBMSHandlerSQLite

public interface DBMSHandler
The DBMSHandler interface implements all RDBMS specific logic
  • Method Details

    • checkExists

      boolean checkExists(DBDatabase db, Connection conn)
      Checks if a database exists
      Parameters:
      db - the database
      conn - the Jdbc connection
      Returns:
      true if database exists of false otherwise
    • attachDatabase

      void attachDatabase(DBDatabase db, Connection conn)
      Called when a database is opened
      Parameters:
      db - the database
      conn - the Jdbc connection
    • detachDatabase

      void detachDatabase(DBDatabase db, Connection conn)
      Called when a database is closed
      Parameters:
      db - the database
      conn - the Jdbc connection
    • createSQLBuilder

      DBSQLBuilder createSQLBuilder()
      This function creates a DBSQLBuilder for this DBMS
      Returns:
      a DBMS specific DBSQLBuilder object
    • createCommand

      DBCommand createCommand(boolean autoPrepareStmt)
      This function creates a DBCommand for this DBMS
      Parameters:
      autoPrepareStmt - whether or not the Command should automatically generate a prepared statement (using ?)
      Returns:
      a DBMS specific DBCommand object
    • createCombinedCommand

      DBCommandExpr createCombinedCommand(DBCommandExpr left, String keyWord, DBCommandExpr right)
      This function gives the dbms a chance to provide a custom implementation for a combined command such as UNION or INTERSECT
      Parameters:
      left - the left command
      keyWord - the key word (either "UNION" or "INTERSECT")
      right - the right command
      Returns:
      a DBCommandExpr object
    • isSupported

      boolean isSupported(DBMSFeature type)
      Returns whether or not a particular feature is supported by this dbms
      Parameters:
      type - type of requested feature. @see DBMSFeature
      Returns:
      true if the features is supported or false otherwise
    • detectQuoteName

      boolean detectQuoteName(DBObject object, String name)
      Returns true if a name needs to be wrapped in quotes or false otherwise
      Parameters:
      name - the name of the object (table, view or column)
    • appendObjectName

      void appendObjectName(DBSQLBuilder sql, String name, Boolean useQuotes)
      Appends a table, view or column name to an SQL phrase.
      Parameters:
      sql - the StringBuilder containing the SQL phrase.
      name - the name of the object (table, view or column)
      useQuotes - use quotes or not. When null is passed then detectQuoteName() is called
    • getSQLPhrase

      String getSQLPhrase(DBSqlPhrase phrase)
      Returns an sql phrase template for this database system.
      Templates for sql function expressions must contain a '?' character which will be replaced by the current column expression.
      If other parameters are necessary the template must contain placeholders like {0}, {1} etc.
      Parameters:
      phrase - the identifier of the phrase
      Returns:
      the phrase template
    • getConvertPhrase

      String getConvertPhrase(DataType destType, DataType srcType, Object format)
      Returns a data type convertion phrase template for this dbms
      The returned template must contain a '?' which will be replaced by a column expression.
      Parameters:
      destType - the target data type
      srcType - the source data type
      format - additional formatting information (optional)
      Returns:
      the data conversion phrase template
    • getUpdateTimestamp

      Timestamp getUpdateTimestamp(Connection conn)
      Returns a DMBS-Timestamp that is used for record updates.
      Parameters:
      conn - the connection that might be used
      Returns:
      the current date and time.
    • getColumnAutoValue

      Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
      Returns an auto-generated value for a particular column
      Parameters:
      db - the database
      column - the column for which a value is required
      conn - a valid database connection
      Returns:
      the auto-generated value
    • getIgnoreCaseExpr

      DBColumnExpr getIgnoreCaseExpr(DBColumnExpr columnExpr)
      Returns an expression that ignores the case of a column expression This is only called for case sensitive column expressions (expr.isCaseSensitive()) Default is upper(expr)
      Parameters:
      columnExpr - the expression for which to ignore the case
      Returns:
      the ignore case expression
    • querySingleValue

      Object querySingleValue(String sqlCmd, Object[] sqlParams, DataType dataType, Connection conn) throws SQLException
      Executes an select SQL-command that returns only one scalar value if no row are returned by the query then ObjectUtils.NO_VALUE is returned
      Parameters:
      sqlCmd - the SQL-Command
      sqlParams - array of sql command parameters used for prepared statements (Optional).
      dataType - the requested return type
      conn - a valid connection to the database.
      Returns:
      the scalar result value or ObjectUtils.NO_VALUE if no row are returned by the query
      Throws:
      SQLException
    • executeSQL

      int executeSQL(String sqlCmd, Object[] sqlParams, Connection conn, DBMSHandler.DBSetGenKeys genKeys) throws SQLException
      Executes an insert, update or delete SQL-command
      Parameters:
      sqlCmd - the SQL-Command
      sqlParams - array of sql command parameters used for prepared statements (Optional).
      conn - a valid connection to the database.
      genKeys - allows to set the auto generated key of a record (INSERT statements only)
      Returns:
      the row count for insert, update or delete or 0 for SQL statements that return nothing
      Throws:
      SQLException - thrown if a database access error occurs
    • executeBatch

      int[] executeBatch(String[] sqlCmd, Object[][] sqlCmdParams, Connection conn) throws SQLException
      Executes a list of sql statements as batch
      Parameters:
      sqlCmd - the sql command
      sqlCmdParams - the command params
      conn - the jdbc connection
      Returns:
      the number of affected records
      Throws:
      SQLException - thrown if a database access error occurs
    • executeQuery

      ResultSet executeQuery(String sqlCmd, Object[] sqlParams, boolean scrollable, Connection conn) throws SQLException
      Executes an select SQL-command and returns the query results
      Parameters:
      sqlCmd - the SQL-Command
      sqlParams - array of sql command parameters used for prepared statements (Optional).
      scrollable - true if scrollable or false otherwise
      conn - a valid connection to the database.
      Returns:
      the JDBC resultset
      Throws:
      SQLException - thrown if a database access error occurs
    • getResultValue

      Object getResultValue(ResultSet rset, int columnIndex, DataType dataType) throws SQLException
      Reads a single column value from the given JDBC ResultSet and returns a value object of desired data type. This gives the dbms the opportunity to change the value i.e. to simulate missing data types with other types.
      Parameters:
      rset - the sql Resultset with the current data row
      columnIndex - one based column Index of the desired column
      dataType - the required data type
      Returns:
      the value of the Column
      Throws:
      SQLException - if a database access error occurs
    • closeResultSet

      void closeResultSet(ResultSet rset)
      Closes the provided JDBC Resultset Use it instead of rset.close() and stmt.close()

      Parameters:
      rset - a ResultSet object
    • getDDLScript

      void getDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script)
      Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.
      Parameters:
      type - operation to perform (CREATE, DROP, ALTER)
      dbo - the object for which to perform the operation (DBDatabase, DBTable, DBView, DBColumn, DBRelation)
      script - the script to which to add the DDL command(s)
    • appendEnableRelationStmt

      void appendEnableRelationStmt(DBRelation r, boolean enable, DBSQLScript script)
      Appends a statement to enable or disable a foreign key relation.
      The default is to drop or create the relation Override this method to provide different behavior for your database.
      Parameters:
      r - the foreign key relation which should be enabled or disabled
      enable - true to enable the relation or false to disable
      script - the script to which to add the DDL command(s)
    • createModelParser

      DBModelParser createModelParser(String catalog, String schema)
      Creates a DataModelParser instance of this DBMSHandler
      Parameters:
      catalog - the database catalog
      schema - the database schema
      Returns:
      the model parser
    • createModelChecker

      DBModelChecker createModelChecker(DBDatabase db)
      Creates a DataModelChecker instance of this DBMSHandler
      Parameters:
      db - the database
      Returns:
      the model checker
    • extractErrorMessage

      String extractErrorMessage(SQLException e)
      Extracts native error message of an sqlExeption.
      Parameters:
      e - the SQLException
      Returns:
      the error message of the database