public abstract class DBMSHandlerBase extends Object implements DBMSHandler
Modifier and Type | Class and Description |
---|---|
static class |
DBMSHandlerBase.DBMSBuilder
DBMSBuilder
A Default DBSQLBuilder implementation with no additional features
|
static class |
DBMSHandlerBase.DBMSCommand
DBMSCommand
A Default DBCommand implementation with no additional features
|
static class |
DBMSHandlerBase.DBSeqTable
This class is used to emulate sequences by using a sequence table.
|
DBMSHandler.DBSetGenKeys
Modifier and Type | Field and Description |
---|---|
protected static String[] |
GENERAL_SQL_KEYWORDS |
protected static char[] |
ILLEGAL_NAME_CHARS |
protected Set<String> |
reservedSQLKeywords |
protected String |
SEQUENCE_NAME_SUFFIX |
Modifier | Constructor and Description |
---|---|
protected |
DBMSHandlerBase()
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addStatementParam(PreparedStatement pstmt,
int paramIndex,
Object value)
Adds a statement parameter to a prepared statement
|
void |
appendEnableRelationStmt(DBRelation r,
boolean enable,
DBSQLScript script)
Appends a statement to enable or disable a foreign key relation.
|
void |
appendObjectName(DBSQLBuilder sql,
String name,
Boolean useQuotes)
Appends a table, view or column name to an SQL phrase.
|
void |
attachDatabase(DBDatabase db,
Connection conn)
Called when a database is opened
|
boolean |
checkExists(DBDatabase db,
Connection conn)
checks if the database exists
The default implementation performs a simple count query on the first table or view
SELECT count(*) FROM table
|
void |
closeResultSet(ResultSet rset)
Convenience function for closing a JDBC Resultset
Use it instead of rset.close() and stmt.close() |
protected void |
closeStatement(Statement stmt)
Convenience function for closing a JDBC Resultset
Use it instead of stmt.close() |
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
|
DBCommand |
createCommand(boolean autoPrepareStmt)
This function creates a DBCommand derived object this database
|
DBModelChecker |
createModelChecker(DBDatabase db)
Creates a DataModelChecker instance of this DBMSHandler
|
DBModelParser |
createModelParser(String catalog,
String schema)
Creates a DataModelParser instance of this DBMSHandler
|
DBSQLBuilder |
createSQLBuilder()
This function creates a DBSQLBuilder for this DBMS
|
void |
detachDatabase(DBDatabase db,
Connection conn)
Called when a database is closed
|
boolean |
detectQuoteName(String name)
Detects whether a table or column name needs to be quoted or not
By default all reserved SQL keywords as well as names containing a "-", "/", "+" or " " require quoting. |
int[] |
executeBatch(String[] sqlCmd,
Object[][] sqlCmdParams,
Connection conn)
Executes a list of sql statements as batch
|
ResultSet |
executeQuery(String sqlCmd,
Object[] sqlParams,
boolean scrollable,
Connection conn)
Executes an select SQL-command and returns the query results
|
int |
executeSQL(String sqlCmd,
Object[] sqlParams,
Connection conn,
DBMSHandler.DBSetGenKeys genKeys)
Executes the select, update or delete SQL-Command with a Statement object.
|
String |
extractErrorMessage(SQLException e)
Extracts native error message of an sqlExeption.
|
Object |
getColumnAutoValue(DBDatabase db,
DBTableColumn column,
Connection conn)
Returns an auto-generated value for a particular column
|
String |
getColumnSequenceName(DBTableColumn column)
Returns the sequence name of for a column of type AUTOINC
The sequence name is usually provided as the default value
If no Default value is provided the sequence name is generated from the table and the column name
|
abstract Object |
getNextSequenceValue(DBDatabase db,
String SeqName,
int minValue,
Connection conn)
Returns the next value of a named sequence The numbers are used for fields of type DBExpr.DT_AUTOINC.
|
abstract DBColumnExpr |
getNextSequenceValueExpr(DBTableColumn column)
Returns an expression for creating a sequence value.
|
Object |
getResultValue(ResultSet rset,
int columnIndex,
DataType dataType)
Reads a single column value from the given JDBC ResultSet and returns a value object of desired data type.
|
Timestamp |
getUpdateTimestamp(Connection conn)
Returns a timestamp that is used for record updates.
|
abstract boolean |
isSupported(DBMSFeature type)
Returns whether or not a particular feature is supported by this dbms
|
protected void |
prepareStatement(PreparedStatement pstmt,
Object[] sqlParams)
Prepares an sql statement by setting the supplied objects as parameters.
|
Object |
querySingleValue(String sqlCmd,
Object[] sqlParams,
DataType dataType,
Connection conn)
Query a single value
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConvertPhrase, getDDLScript, getSQLPhrase
protected static final char[] ILLEGAL_NAME_CHARS
protected static final String[] GENERAL_SQL_KEYWORDS
protected String SEQUENCE_NAME_SUFFIX
public boolean checkExists(DBDatabase db, Connection conn)
checkExists
in interface DBMSHandler
public void attachDatabase(DBDatabase db, Connection conn)
attachDatabase
in interface DBMSHandler
public void detachDatabase(DBDatabase db, Connection conn)
detachDatabase
in interface DBMSHandler
public DBSQLBuilder createSQLBuilder()
createSQLBuilder
in interface DBMSHandler
public DBCommand createCommand(boolean autoPrepareStmt)
createCommand
in interface DBMSHandler
autoPrepareStmt
- flag whether to automatically provide literal values as prepared statement paramspublic DBCommandExpr createCombinedCommand(DBCommandExpr left, String keyWord, DBCommandExpr right)
createCombinedCommand
in interface DBMSHandler
left
- the left commandkeyWord
- the key word (either "UNION" or "INTERSECT")left
- the right commandpublic abstract boolean isSupported(DBMSFeature type)
isSupported
in interface DBMSHandler
type
- type of requested feature. @see DBMSFeaturepublic boolean detectQuoteName(String name)
public void appendObjectName(DBSQLBuilder sql, String name, Boolean useQuotes)
appendObjectName
in interface DBMSHandler
sql
- the StringBuilder containing the SQL phrase.name
- the name of the object (table, view or column)useQuotes
- use quotes or notpublic Timestamp getUpdateTimestamp(Connection conn)
getUpdateTimestamp
in interface DBMSHandler
conn
- the connection that might be usedpublic abstract Object getNextSequenceValue(DBDatabase db, String SeqName, int minValue, Connection conn)
db
- the databaseSeqName
- the name of the sequenceminValue
- the minimum value of the sequenceconn
- a valid database connectionpublic abstract DBColumnExpr getNextSequenceValueExpr(DBTableColumn column)
column
- the column for which to obtain an expression providing the next sequence valuepublic String getColumnSequenceName(DBTableColumn column)
public Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
getColumnAutoValue
in interface DBMSHandler
db
- the databasecolumn
- the column for which a value is requiredconn
- a valid database connectionpublic Object getResultValue(ResultSet rset, int columnIndex, DataType dataType) throws SQLException
getResultValue
in interface DBMSHandler
rset
- the sql Resultset with the current data rowcolumnIndex
- one based column Index of the desired columndataType
- the required data typeSQLException
- if a database access error occurspublic int executeSQL(String sqlCmd, Object[] sqlParams, Connection conn, DBMSHandler.DBSetGenKeys genKeys) throws SQLException
executeSQL
in interface DBMSHandler
sqlCmd
- the SQL-CommandsqlParams
- 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)SQLException
- if a database access error occurspublic int[] executeBatch(String[] sqlCmd, Object[][] sqlCmdParams, Connection conn) throws SQLException
executeBatch
in interface DBMSHandler
sqlCmd
- an array of sql statementssqlCmdParams
- and array of statement parametersconn
- a JDBC connectionSQLException
public ResultSet executeQuery(String sqlCmd, Object[] sqlParams, boolean scrollable, Connection conn) throws SQLException
executeQuery
in interface DBMSHandler
sqlCmd
- the SQL-CommandsqlParams
- array of sql command parameters used for prepared statements (Optional).scrollable
- true if scrollable or false otherwiseconn
- a valid connection to the database.SQLException
public Object querySingleValue(String sqlCmd, Object[] sqlParams, DataType dataType, Connection conn)
querySingleValue
in interface DBMSHandler
sqlCmd
- the SQL-CommandsqlParams
- array of sql command parameters used for prepared statements (Optional).dataType
- the requested return typeconn
- a valid connection to the database.public void appendEnableRelationStmt(DBRelation r, boolean enable, DBSQLScript script)
appendEnableRelationStmt
in interface DBMSHandler
r
- the foreign key relation which should be enabled or disabledenable
- true to enable the relation or false to disablescript
- the script to which to add the DDL command(s)public DBModelParser createModelParser(String catalog, String schema)
createModelParser
in interface DBMSHandler
public DBModelChecker createModelChecker(DBDatabase db)
createModelChecker
in interface DBMSHandler
public String extractErrorMessage(SQLException e)
extractErrorMessage
in interface DBMSHandler
e
- the SQLExceptionpublic void closeResultSet(ResultSet rset)
closeResultSet
in interface DBMSHandler
rset
- a ResultSet objectprotected void closeStatement(Statement stmt)
stmt
- a Statement objectprotected void prepareStatement(PreparedStatement pstmt, Object[] sqlParams) throws SQLException
pstmt
- the prepared statementsqlParams
- list of objectsSQLException
protected void addStatementParam(PreparedStatement pstmt, int paramIndex, Object value) throws SQLException
pstmt
- the prepared statementparamIndex
- the parameter indexvalue
- the parameter valueSQLException
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.