Package org.apache.empire.dbms.mysql
Class DBMSHandlerMySQL
java.lang.Object
org.apache.empire.dbms.DBMSHandlerBase
org.apache.empire.dbms.mysql.DBMSHandlerMySQL
- All Implemented Interfaces:
DBMSHandler
This class provides support for the MySQL database system.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines the MySQL command type.static classProvides a DBSQLBuilder implementation for MySQLNested classes/interfaces inherited from class org.apache.empire.dbms.DBMSHandlerBase
DBMSHandlerBase.DBMSBuilder, DBMSHandlerBase.DBMSCommand, DBMSHandlerBase.DBSeqTableNested classes/interfaces inherited from interface org.apache.empire.dbms.DBMSHandler
DBMSHandler.DBSetGenKeys -
Field Summary
FieldsFields inherited from class org.apache.empire.dbms.DBMSHandlerBase
GENERAL_SQL_KEYWORDS, ILLEGAL_NAME_CHARS, reservedSQLKeywords, SEQUENCE_NAME_SUFFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachDatabase(DBDatabase db, Connection conn) Called when a database is openedcreateCombinedCommand(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 INTERSECTcreateCommand(boolean autoPrepareStmt) Creates a new MySQL command object.Creates a new MySQL SQL-Builder.getConvertPhrase(DataType destType, DataType srcType, Object format) Returns a data type convertion phrase template for this dbms
The returned template must contain a '?'returns the name for the database / schemavoidgetDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script) Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.Get the table engine that is used when creating new tablesgetNextSequenceValue(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.
If a dbms supports this function it must return true for isSupported(DBMSFeature.SEQUENCES).Returns an expression for creating a sequence value.returns the name of the sequence tablegetSQLPhrase(DBSqlPhrase phrase) Gets an sql phrase template for this database system.getUpdateTimestamp(Connection conn) Overridden.booleanisSupported(DBMSFeature type) Returns whether or not a particular feature is supported by this dbmsbooleanreturns whether a sequence table is used for record identity management.
Default is false.voidsetCharacterSet(String characterSet) voidsetDatabaseName(String databaseName) Sets the name for the database / schema
This names is required for creating a database.
When a name is set, the dbms will automatically execute 'USE dbname' when the database is opened.voidSet the table engine that is used when creating new tablesvoidsetSequenceTableName(String sequenceTableName) Sets the name of the sequence table.voidsetUseSequenceTable(boolean useSequenceTable) If set to true a special table is used for sequence number generation.
Otherwise the AutoIncrement feature of MySQL is used identity fields.Methods inherited from class org.apache.empire.dbms.DBMSHandlerBase
addSQLKeyword, addStatementParam, appendEnableRelationStmt, appendObjectName, checkExists, closeResultSet, closeStatement, createModelChecker, createModelParser, detachDatabase, detectQuoteName, executeBatch, executeQuery, executeSQL, extractErrorMessage, getColumnAutoValue, getColumnSequenceName, getIgnoreCaseExpr, getResultValue, prepareStatement, querySingleValue
-
Field Details
-
MYSQL_KEYWORDS
-
-
Constructor Details
-
DBMSHandlerMySQL
public DBMSHandlerMySQL()Constructor for the MySQL database dbms.
-
-
Method Details
-
getDatabaseName
returns the name for the database / schema- Returns:
- the database / schema name
-
setDatabaseName
Sets the name for the database / schema
This names is required for creating a database.
When a name is set, the dbms will automatically execute 'USE dbname' when the database is opened.- Parameters:
databaseName- the name of the database
-
getCharacterSet
-
setCharacterSet
-
getEngine
Get the table engine that is used when creating new tables- Returns:
- the table engine
-
setEngine
Set the table engine that is used when creating new tables- Parameters:
engine- the table engine
-
isUseSequenceTable
public boolean isUseSequenceTable()returns whether a sequence table is used for record identity management.
Default is false. In this case the AutoIncrement feature of MySQL is used.- Returns:
- true if a sequence table is used instead of identity columns.
-
setUseSequenceTable
public void setUseSequenceTable(boolean useSequenceTable) If set to true a special table is used for sequence number generation.
Otherwise the AutoIncrement feature of MySQL is used identity fields.- Parameters:
useSequenceTable- true to use a sequence table or false otherwise.
-
getSequenceTableName
returns the name of the sequence table- Returns:
- the name of the table used for sequence number generation
-
setSequenceTableName
Sets the name of the sequence table. Only applicable if useSequenceTable is set to true.- Parameters:
sequenceTableName- the name of the table used for sequence number generation
-
attachDatabase
Description copied from class:DBMSHandlerBaseCalled when a database is opened- Specified by:
attachDatabasein interfaceDBMSHandler- Overrides:
attachDatabasein classDBMSHandlerBase- Parameters:
db- the databaseconn- the Jdbc connection
-
createCommand
Creates a new MySQL command object.- Specified by:
createCommandin interfaceDBMSHandler- Overrides:
createCommandin classDBMSHandlerBase- Parameters:
autoPrepareStmt- flag whether to automatically provide literal values as prepared statement params- Returns:
- the new DBCommandMySQL object
-
createSQLBuilder
Creates a new MySQL SQL-Builder.- Specified by:
createSQLBuilderin interfaceDBMSHandler- Overrides:
createSQLBuilderin classDBMSHandlerBase- Returns:
- the new DBSQLBuilder object
-
createCombinedCommand
Description copied from class:DBMSHandlerBaseThis function gives the dbms a chance to provide a custom implementation for a combined command such as UNION or INTERSECT- Specified by:
createCombinedCommandin interfaceDBMSHandler- Overrides:
createCombinedCommandin classDBMSHandlerBase- Parameters:
left- the left commandkeyWord- the key word (either "UNION" or "INTERSECT")right- the right command- Returns:
- a DBCommandExpr object
-
isSupported
Returns whether or not a particular feature is supported by this dbms- Specified by:
isSupportedin interfaceDBMSHandler- Specified by:
isSupportedin classDBMSHandlerBase- Parameters:
type- type of requested feature. @see DBMSFeature- Returns:
- true if the features is supported or false otherwise
-
getSQLPhrase
Gets an sql phrase template for this database system.- Parameters:
phrase- the identifier of the phrase- Returns:
- the phrase template
- See Also:
-
getConvertPhrase
Description copied from interface:DBMSHandlerReturns 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 typesrcType- the source data typeformat- additional formatting information (optional)- Returns:
- the data conversion phrase template
- See Also:
-
getNextSequenceValue
Description copied from class:DBMSHandlerBaseReturns the next value of a named sequence The numbers are used for fields of type DBExpr.DT_AUTOINC.
If a dbms supports this function it must return true for isSupported(DBMSFeature.SEQUENCES).- Specified by:
getNextSequenceValuein classDBMSHandlerBase- Parameters:
db- the databaseseqName- the name of the sequenceminValue- the minimum value of the sequenceconn- a valid database connection- Returns:
- a new unique sequence value or null if an error occurred
- See Also:
-
getNextSequenceValueExpr
Description copied from class:DBMSHandlerBaseReturns an expression for creating a sequence value. This is intended for the use with INSERT INTO statements where many records are affected.- Specified by:
getNextSequenceValueExprin classDBMSHandlerBase- Parameters:
column- the column for which to obtain an expression providing the next sequence value- Returns:
- an expression for the next sequence value
- See Also:
-
getUpdateTimestamp
Overridden. Returns a timestamp that is used for record updates created by the database server.- Specified by:
getUpdateTimestampin interfaceDBMSHandler- Overrides:
getUpdateTimestampin classDBMSHandlerBase- Parameters:
conn- the connection that might be used- Returns:
- the current date and time of the database server.
-
getDDLScript
Description copied from interface:DBMSHandlerAppends 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)- See Also:
-