public class MySqlEngine extends AbstractDatabaseEngine
| Modifier and Type | Field and Description |
|---|---|
static java.util.List<java.lang.Integer> |
CONSTRAINT_NAME_ALREADY_EXISTS
Foreign Key already exists.
|
static int |
DUPLICATE_KEY_NAME
Duplicate key name
|
protected static java.lang.String |
MYSQL_DRIVER
The MySQL JDBC driver.
|
static int |
TABLE_CAN_ONLY_HAVE_ONE_PRIMARY_KEY
Table can have only one primary key.
|
static int |
TABLE_DOES_NOT_EXIST
Table or view does not exist.
|
static int |
TABLE_NAME_ALREADY_EXISTS
Table name is already used by an existing object.
|
conn, currentSchema, dev, dialect, eh, entities, injector, logger, notificationLogger, properties, stmts, translator| Constructor and Description |
|---|
MySqlEngine(PdbProperties properties)
Creates a new MySQL connection.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addColumn(DbEntity entity,
DbColumn... columns)
Adds the column to an existent table.
|
protected void |
addFks(DbEntity entity)
Adds the FKs.
|
protected void |
addIndexes(DbEntity entity)
Add the desired indexes.
|
protected void |
addPrimaryKey(DbEntity entity)
Add a primary key to the entity.
|
protected void |
addSequences(DbEntity entity)
Adds the necessary sequences.
|
protected boolean |
checkConnection(java.sql.Connection conn)
Checks if the connection is alive.
|
java.lang.String |
commentCharacter() |
protected MappedEntity |
createPreparedStatementForInserts(DbEntity entity)
Creates and gets the prepared statement that will be used for insertions.
|
protected ResultIterator |
createResultIterator(java.sql.PreparedStatement ps)
Creates a specific
ResultIterator for the engine in place given given prepared statement. |
protected ResultIterator |
createResultIterator(java.sql.Statement statement,
java.lang.String sql)
Creates a specific
ResultIterator given the engine implementation. |
protected void |
createTable(DbEntity entity)
Creates the table.
|
protected void |
dropColumn(DbEntity entity,
java.lang.String... columns)
Drops the column.
|
protected void |
dropFks(java.lang.String table)
Drops this table foreign keys.
|
protected void |
dropReferringFks(DbEntity entity) |
protected void |
dropSequences(DbEntity entity)
Drops the sequences of the entity.
|
protected void |
dropTable(DbEntity entity)
Drops the table.
|
protected int |
entityToPreparedStatement(DbEntity entity,
java.sql.PreparedStatement ps,
EntityEntry entry,
boolean useAutoInc)
Translates the given entry entity to the prepared statement.
|
java.lang.String |
escapeCharacter() |
java.util.Map<java.lang.String,DbEntityType> |
getEntities(java.lang.String schemaPattern)
Gets the database entities for the specified schema.
|
java.util.Map<java.lang.String,DbColumnType> |
getMetadata(java.lang.String schemaPattern,
java.lang.String tableNamePattern)
Gets the table metadata (table must be in the current schema).
|
protected java.lang.String |
getSchema()
Gets the schema being used in the current
connection. |
java.lang.Class<? extends AbstractTranslator> |
getTranslatorClass()
Gets the class that translates SQL bound to this engine.
|
ResultIterator |
iterator(java.lang.String query)
Creates an iterator for the given SQL sentence.
|
java.lang.Long |
persist(java.lang.String name,
EntityEntry entry)
Persists a given entry.
|
java.lang.Long |
persist(java.lang.String name,
EntityEntry entry,
boolean useAutoInc)
Persists a given entry.
|
protected void |
setSchema(java.lang.String schema)
Sets the schema for the current
connection. |
protected java.lang.String |
translateType(DbColumn c)
Translates the type present in the given column.
|
addBatch, addEntity, beginTransaction, checkConnection, checkConnection, clearParameters, close, commit, connect, containsEntity, createBatch, createBatch, createBatch, createPreparedStatement, createPreparedStatement, createPreparedStatement, createPreparedStatement, dropEntity, dropEntity, duplicate, executePS, executePSUpdate, executeUpdate, executeUpdate, executeUpdateSilently, flush, getConnection, getDialect, getEntities, getFinalJdbcConnection, getMetadata, getPrivateKey, getProperties, getPSIterator, getPSIterator, getPSResultSet, getQueryMetadata, getQueryMetadata, handleOperation, hasIdentityColumn, inject, isTransactionActive, iterator, iterator, iterator, loadEntity, objectToArray, preparedStatementExists, processResultIterator, query, query, removeEntity, removePreparedStatement, rollback, setExceptionHandler, setParameter, setParameter, setParameters, setParameterValues, setTransactionIsolation, toPdbType, translate, updateEntityprotected static final java.lang.String MYSQL_DRIVER
public static final int TABLE_NAME_ALREADY_EXISTS
public static final int DUPLICATE_KEY_NAME
public static final int TABLE_CAN_ONLY_HAVE_ONE_PRIMARY_KEY
public static final int TABLE_DOES_NOT_EXIST
public static final java.util.List<java.lang.Integer> CONSTRAINT_NAME_ALREADY_EXISTS
public MySqlEngine(PdbProperties properties) throws DatabaseEngineException
properties - The properties for the database connection.DatabaseEngineException - When the connection fails.protected int entityToPreparedStatement(DbEntity entity, java.sql.PreparedStatement ps, EntityEntry entry, boolean useAutoInc) throws DatabaseEngineException
AbstractDatabaseEngineentityToPreparedStatement in class AbstractDatabaseEngineentity - The entity.ps - The prepared statement.entry - The entry.DatabaseEngineException - if something occurs during the translation.protected void createTable(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginecreateTable in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addPrimaryKey(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddPrimaryKey in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addIndexes(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddIndexes in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addSequences(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddSequences in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected MappedEntity createPreparedStatementForInserts(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginecreatePreparedStatementForInserts in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void dropSequences(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginedropSequences in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong dropping the sequences.protected void dropTable(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginedropTable in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong dropping the sequences.protected void dropColumn(DbEntity entity, java.lang.String... columns) throws DatabaseEngineException
AbstractDatabaseEnginedropColumn in class AbstractDatabaseEngineentity - The entity.columns - The column name to drop.DatabaseEngineException - If something goes wrong dropping the sequences.protected void addColumn(DbEntity entity, DbColumn... columns) throws DatabaseEngineException
AbstractDatabaseEngineaddColumn in class AbstractDatabaseEngineentity - The entity that represents the table.columns - The db column to add.DatabaseEngineException - If something goes wrong adding columns.protected java.lang.String translateType(DbColumn c) throws DatabaseEngineException
AbstractDatabaseEnginetranslateType in class AbstractDatabaseEnginec - The column.DatabaseEngineException - If the type cannot be found.public java.lang.Class<? extends AbstractTranslator> getTranslatorClass()
AbstractDatabaseEnginegetTranslatorClass in class AbstractDatabaseEnginepublic java.lang.Long persist(java.lang.String name,
EntityEntry entry)
throws DatabaseEngineException
AbstractDatabaseEngineIf you are inside of an explicit transaction, changes will only be visible upon explicit commit, otherwise a commit will immediately take place.
persist in interface DatabaseEnginepersist in class AbstractDatabaseEnginename - The entity name.entry - The entry to persist.DatabaseEngineException - If something goes wrong while persisting data.public java.lang.Long persist(java.lang.String name,
EntityEntry entry,
boolean useAutoInc)
throws DatabaseEngineException
AbstractDatabaseEnginePersists a given entry. Persisting a query implies executing the statement. If define useAutoInc as false, PDB will disable the auto increments for the current insert and advance the sequences if needed.
If you are inside of an explicit transaction, changes will only be visible upon explicit commit, otherwise a commit will immediately take place.
persist in interface DatabaseEnginepersist in class AbstractDatabaseEnginename - The entity name.entry - The entry to persist.useAutoInc - Use or not the autoinc.DatabaseEngineException - If something goes wrong while persisting data.protected void addFks(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddFks in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong creating the FKs.protected void dropFks(java.lang.String table)
throws DatabaseEngineException
AbstractDatabaseEnginedropFks in class AbstractDatabaseEnginetable - The table name.DatabaseEngineException - If something goes wrong dropping the FKs.protected void dropReferringFks(DbEntity entity) throws DatabaseEngineException
DatabaseEngineExceptionpublic java.util.Map<java.lang.String,DbEntityType> getEntities(java.lang.String schemaPattern) throws DatabaseEngineException
DatabaseEnginegetEntities in interface DatabaseEnginegetEntities in class AbstractDatabaseEngineschemaPattern - A schema name pattern; must match the schema name as it is stored in the database;
"" retrieves those without a schema; null means that the schema name
should not be used to narrow the search.DatabaseEngineException - If something occurs getting the existing tables.protected boolean checkConnection(java.sql.Connection conn)
AbstractDatabaseEnginecheckConnection in class AbstractDatabaseEngineconn - The connection to test.protected java.lang.String getSchema()
throws DatabaseEngineException
AbstractDatabaseEngineconnection.getSchema in class AbstractDatabaseEnginenull if there is none.DatabaseEngineException - If a database access error occurs or this method is called on a closed connection.protected void setSchema(java.lang.String schema)
throws DatabaseEngineException
AbstractDatabaseEngineconnection.setSchema in class AbstractDatabaseEngineDatabaseEngineException - If schema doesn't exist, a database access error occurs or this method
is called on a closed connection.public java.util.Map<java.lang.String,DbColumnType> getMetadata(java.lang.String schemaPattern, java.lang.String tableNamePattern) throws DatabaseEngineException
DatabaseEnginegetMetadata in interface DatabaseEnginegetMetadata in class AbstractDatabaseEngineschemaPattern - A schema name pattern; must match the schema name as it is stored in the database;
"" retrieves those without a schema; null means that the schema name
should not be used to narrow the search.tableNamePattern - A table name pattern; must match the table name as it is stored in the database.DatabaseEngineException - If something occurs getting the metadata.public ResultIterator iterator(java.lang.String query) throws DatabaseEngineException
DatabaseEngineiterator in interface DatabaseEngineiterator in class AbstractDatabaseEnginequery - The query.DatabaseEngineException - If a database access error occurs.public java.lang.String commentCharacter()
commentCharacter in interface DatabaseEnginecommentCharacter in class AbstractDatabaseEnginepublic java.lang.String escapeCharacter()
escapeCharacter in interface DatabaseEngineescapeCharacter in class AbstractDatabaseEngineprotected ResultIterator createResultIterator(java.sql.Statement statement, java.lang.String sql) throws DatabaseEngineException
AbstractDatabaseEngineResultIterator given the engine implementation.createResultIterator in class AbstractDatabaseEnginestatement - The statement.sql - The SQL sentence.DatabaseEngineException - If a database access error occurs.protected ResultIterator createResultIterator(java.sql.PreparedStatement ps) throws DatabaseEngineException
AbstractDatabaseEngineResultIterator for the engine in place given given prepared statement.createResultIterator in class AbstractDatabaseEngineps - The prepared statement.DatabaseEngineException - If a database access error occurs.Copyright © 2018 Feedzai. All Rights Reserved.