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, waitgetConvertPhrase, getDDLScript, getSQLPhraseprotected 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 DBMSHandlerdb - the databaseconn - the Jdbc connectionpublic void attachDatabase(DBDatabase db, Connection conn)
attachDatabase in interface DBMSHandlerdb - the databaseconn - the Jdbc connectionpublic void detachDatabase(DBDatabase db, Connection conn)
detachDatabase in interface DBMSHandlerdb - the databaseconn - the Jdbc connectionpublic DBSQLBuilder createSQLBuilder()
createSQLBuilder in interface DBMSHandlerpublic DBCommand createCommand(boolean autoPrepareStmt)
createCommand in interface DBMSHandlerautoPrepareStmt - flag whether to automatically provide literal values as prepared statement paramspublic DBCommandExpr createCombinedCommand(DBCommandExpr left, String keyWord, DBCommandExpr right)
createCombinedCommand in interface DBMSHandlerleft - the left commandkeyWord - the key word (either "UNION" or "INTERSECT")left - the right commandright - the right commandpublic abstract boolean isSupported(DBMSFeature type)
isSupported in interface DBMSHandlertype - type of requested feature. @see DBMSFeaturepublic boolean detectQuoteName(String name)
name - the name which to checkpublic void appendObjectName(DBSQLBuilder sql, String name, Boolean useQuotes)
appendObjectName in interface DBMSHandlersql - 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 DBMSHandlerconn - 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)
column - the column for which to get a sequencepublic Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
getColumnAutoValue in interface DBMSHandlerdb - 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 DBMSHandlerrset - 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 DBMSHandlersqlCmd - 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 DBMSHandlersqlCmd - an array of sql statementssqlCmdParams - and array of statement parametersconn - a JDBC connectionSQLException - thrown if a database access error occurspublic ResultSet executeQuery(String sqlCmd, Object[] sqlParams, boolean scrollable, Connection conn) throws SQLException
executeQuery in interface DBMSHandlersqlCmd - 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 - thrown if a database access error occurspublic Object querySingleValue(String sqlCmd, Object[] sqlParams, DataType dataType, Connection conn)
querySingleValue in interface DBMSHandlersqlCmd - 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 DBMSHandlerr - 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 DBMSHandlercatalog - the database catalogschema - the database schemapublic DBModelChecker createModelChecker(DBDatabase db)
createModelChecker in interface DBMSHandlerdb - the databasepublic String extractErrorMessage(SQLException e)
extractErrorMessage in interface DBMSHandlere - the SQLExceptionpublic void closeResultSet(ResultSet rset)
closeResultSet in interface DBMSHandlerrset - 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 - thrown if a database access error occursprotected void addStatementParam(PreparedStatement pstmt, int paramIndex, Object value) throws SQLException
pstmt - the prepared statementparamIndex - the parameter indexvalue - the parameter valueSQLException - thrown if a database access error occursCopyright © 2008–2023 Apache Software Foundation. All rights reserved.