|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.database.AbstractDatabase
com.continuent.tungsten.replicator.database.MySQLDatabase
public class MySQLDatabase
Implements DBMS-specific operations for MySQL.
| Field Summary |
|---|
| Fields inherited from class com.continuent.tungsten.replicator.database.AbstractDatabase |
|---|
autoCommit, connected, dbConn, dbDriver, dbms, dbPassword, dbUri, dbUser, defaultSchema, drivers, privileged |
| Fields inherited from interface com.continuent.tungsten.replicator.database.Database |
|---|
MYSQL, ORACLE, POSTGRESQL, UNKNOWN |
| Constructor Summary | |
|---|---|
MySQLDatabase()
|
|
| Method Summary | |
|---|---|
protected java.lang.String |
columnToTypeString(Column c,
java.lang.String tableType)
Return a properly constructed type specification for the column. |
void |
connect()
Connect to a MySQL database, which includes setting the wait_timeout to a very high value so we don't lose our connection. |
void |
connect(boolean binlog)
Connect to a MySQL database, which includes setting the wait_timeout to a very high value so we don't lose our connection. |
void |
controlSessionLevelLogging(boolean suppressed)
Sets session-level logging of updates. |
void |
createSchema(java.lang.String schema)
Creates the named schema. |
void |
createTable(Table t,
boolean replace)
This should not be called for MySQL but we have a version of it anyway because it's better not to have broken code. |
void |
createTable(Table t,
boolean replace,
java.lang.String tableType)
Stub routine that ignores table type. |
void |
createUser(User user)
Creates a user that can connect from any location. |
void |
dropSchema(java.lang.String schema)
Drops the named schema. |
void |
dropUser(User user,
boolean ignore)
Drops user, ignoring errors if desired by caller. |
java.sql.ResultSet |
getColumnsResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
This function should be implemented in concrete class. |
java.lang.String |
getControlTimestampQuery(java.lang.Long timestamp)
MySQL supports the 'set timestamp' command, which is what we return. |
CsvWriter |
getCsvWriter(java.io.BufferedWriter writer)
Returns a properly configured CsvWriter to generate CSV according to the preferred conventions of this DBMS type. |
java.lang.String |
getDatabaseObjectName(java.lang.String name)
Returns the eventually quoted database object name. |
java.lang.String |
getNowFunction()
getNowFunction returns the database-specific way to get current date and time from the database. |
java.lang.String |
getPlaceHolder(OneRowChange.ColumnSpec col,
java.lang.Object colValue,
java.lang.String typeDesc)
Return a place holder in a prepared statement for a column of type ColumnSpec. |
protected java.sql.ResultSet |
getPrimaryKeyResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
This function should be implemented in concrete class. |
java.util.ArrayList<java.lang.String> |
getSchemas()
Returns a list of schemas available on the server. |
java.lang.String |
getSessionVariable(java.lang.String name)
Gets a variable on the current session. |
SqlOperationMatcher |
getSqlNameMatcher()
Returns a SQL name matcher for this database type. |
protected java.sql.ResultSet |
getTablesResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
boolean baseTablesOnly)
This function should be implemented in concrete class. |
java.lang.String |
getTimeDiff(java.lang.String string1,
java.lang.String string2)
getTimeDiff returns the database-specific way of subtracting two "dates" and return the result in seconds complete with space for the two bind variables. |
java.lang.String |
getUseSchemaQuery(java.lang.String schema)
Returns a query that can be used to set the schema. |
void |
kill(Session session)
Issue a KILL command to remove a particular session. |
java.util.List<Session> |
listSessions()
Issue SHOW PROCESSLIST command to get a list of all currently available sessions. |
boolean |
nullsBoundDifferently(OneRowChange.ColumnSpec col)
Return TRUE IFF NULL values are bound differently in SQL statement from non null values for the given column type. |
boolean |
nullsEverBoundDifferently()
return true IFF nulls are sometimes treated differently in nullsBoundDifferently() as non nulls. |
java.lang.String |
prepareOptionSetStatement(java.lang.String optionName,
java.lang.String optionValue)
prepareOptionSetStatement generates the sql statement that is to be used to set an option (or a session variable) at the database connection level. |
void |
setSessionVariable(java.lang.String name,
java.lang.String value)
Sets a variable on the current session using MySQL SET command. |
protected boolean |
supportsCharset(java.lang.String tableType)
|
boolean |
supportsControlSessionLevelLogging()
Returns true if this implementation allow clients to turn logging of SQL updates on and off at the session level. |
boolean |
supportsControlTimestamp()
By default we do not support controlling the timestamp. |
boolean |
supportsCreateDropSchema()
Returns false by default as only some database types allow schema to be created dynamically. |
boolean |
supportsNativeSlaveSync()
Returns true if this implementation supports synchronization of native slave replication with Tungsten position. |
protected boolean |
supportsNotNull(java.lang.String tableType)
|
protected boolean |
supportsPrimaryKeys(java.lang.String tableType)
|
boolean |
supportsReplace()
Returns true if the implementation supports a SQL REPLACE command. |
boolean |
supportsSessionVariables()
MySQL supports session variables. |
boolean |
supportsUseDefaultSchema()
Returns false by default as only some database types allow schema to change. |
boolean |
supportsUserManagement()
Returns true if this implementation supports user management commands. |
void |
syncNativeSlave(java.lang.String eventId)
Synchronize the native slave position with Tungsten so that native replication can start properly after Tungsten goes offline. |
void |
useDefaultSchema(java.lang.String schema)
Changes the default schema to the named schema. |
| Methods inherited from class com.continuent.tungsten.replicator.database.AbstractDatabase |
|---|
close, commit, consistencyCheck, consistencyCheck, createStatement, createTable, createTable, delete, disconnect, dropTable, dropTungstenCatalog, execute, executeUpdate, findTable, findTable, findTable, getBlobAsBytes, getConnection, getDatabaseMetaData, getReservedWords, getTables, getType, insert, isPrivileged, javaSQLTypeToNativeType, nativeTypeToJavaSQLType, prepareStatement, replace, rollback, setAutoCommit, setPassword, setPrivileged, setUrl, setUser, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MySQLDatabase()
throws java.sql.SQLException
java.sql.SQLException| Method Detail |
|---|
protected java.lang.String columnToTypeString(Column c,
java.lang.String tableType)
AbstractDatabase
columnToTypeString in class AbstractDatabasec - Column for which specification is required
public void connect()
throws java.sql.SQLException
connect in interface Databaseconnect in class AbstractDatabasejava.sql.SQLExceptionAbstractDatabase.connect()
public void connect(boolean binlog)
throws java.sql.SQLException
connect in interface Databaseconnect in class AbstractDatabasebinlog - log connection updates.
java.sql.SQLExceptionAbstractDatabase.connect(boolean)
public void createTable(Table t,
boolean replace)
throws java.sql.SQLException
createTable in interface DatabasecreateTable in class AbstractDatabaset - Table specificationreplace - If true, replace an existing table
java.sql.SQLExceptionDatabase.createTable(com.continuent.tungsten.replicator.database.Table,
boolean)public boolean supportsReplace()
Database
supportsReplace in interface DatabasesupportsReplace in class AbstractDatabasepublic boolean supportsUseDefaultSchema()
AbstractDatabase
supportsUseDefaultSchema in interface DatabasesupportsUseDefaultSchema in class AbstractDatabaseDatabase.supportsUseDefaultSchema()
public void useDefaultSchema(java.lang.String schema)
throws java.sql.SQLException
AbstractDatabase
useDefaultSchema in interface DatabaseuseDefaultSchema in class AbstractDatabasejava.sql.SQLExceptionDatabase.useDefaultSchema(java.lang.String)public java.lang.String getUseSchemaQuery(java.lang.String schema)
AbstractDatabase
getUseSchemaQuery in interface DatabasegetUseSchemaQuery in class AbstractDatabaseDatabase.getUseSchemaQuery(java.lang.String)public boolean supportsCreateDropSchema()
AbstractDatabase
supportsCreateDropSchema in interface DatabasesupportsCreateDropSchema in class AbstractDatabaseDatabase.supportsCreateDropSchema()
public void createSchema(java.lang.String schema)
throws java.sql.SQLException
AbstractDatabase
createSchema in interface DatabasecreateSchema in class AbstractDatabasejava.sql.SQLExceptionDatabase.createSchema(java.lang.String)
public void dropSchema(java.lang.String schema)
throws java.sql.SQLException
AbstractDatabase
dropSchema in interface DatabasedropSchema in class AbstractDatabasejava.sql.SQLExceptionDatabase.dropSchema(java.lang.String)public boolean supportsControlSessionLevelLogging()
supportsControlSessionLevelLogging in interface DatabasesupportsControlSessionLevelLogging in class AbstractDatabaseDatabase.supportsControlSessionLevelLogging()
public void controlSessionLevelLogging(boolean suppressed)
throws java.sql.SQLException
controlSessionLevelLogging in interface DatabasecontrolSessionLevelLogging in class AbstractDatabasesuppressed - If true, updates are not logged; otherwise logging is
turned on
java.sql.SQLExceptionDatabase.controlSessionLevelLogging(boolean)public boolean supportsNativeSlaveSync()
supportsNativeSlaveSync in interface DatabasesupportsNativeSlaveSync in class AbstractDatabaseAbstractDatabase.supportsNativeSlaveSync()
public void syncNativeSlave(java.lang.String eventId)
throws java.sql.SQLException
syncNativeSlave in interface DatabasesyncNativeSlave in class AbstractDatabaseeventId - Tungsten event ID containing native log coordinates
java.sql.SQLExceptionAbstractDatabase.syncNativeSlave(java.lang.String)public boolean supportsControlTimestamp()
AbstractDatabase
supportsControlTimestamp in interface DatabasesupportsControlTimestamp in class AbstractDatabaseDatabase.supportsControlTimestamp()public java.lang.String getControlTimestampQuery(java.lang.Long timestamp)
getControlTimestampQuery in interface DatabasegetControlTimestampQuery in class AbstractDatabasetimestamp - Time in milliseconds according to Java standardAbstractDatabase.supportsControlTimestamp()public boolean supportsSessionVariables()
supportsSessionVariables in interface DatabasesupportsSessionVariables in class AbstractDatabaseDatabase.supportsSessionVariables()
public void setSessionVariable(java.lang.String name,
java.lang.String value)
throws java.sql.SQLException
setSessionVariable in interface DatabasesetSessionVariable in class AbstractDatabasename - Name of the variable to setvalue - Value to set
java.sql.SQLException - Thrown if setting variable is unsuccessfulDatabase.setSessionVariable(java.lang.String,
java.lang.String)
public java.lang.String getSessionVariable(java.lang.String name)
throws java.sql.SQLException
getSessionVariable in interface DatabasegetSessionVariable in class AbstractDatabasename - Name of the variable to get
java.sql.SQLException - Thrown if getting variable is unsuccessfulDatabase.getSessionVariable(java.lang.String)
public java.util.ArrayList<java.lang.String> getSchemas()
throws java.sql.SQLException
Database
java.sql.SQLException
public java.sql.ResultSet getColumnsResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
throws java.sql.SQLException
AbstractDatabase
getColumnsResultSet in interface DatabasegetColumnsResultSet in class AbstractDatabasemd - DatabaseMetaData objectschemaName - schema nametableName - table name
java.sql.SQLException
protected java.sql.ResultSet getPrimaryKeyResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
throws java.sql.SQLException
AbstractDatabase
getPrimaryKeyResultSet in class AbstractDatabasemd - DatabaseMetaData objectschemaName - schema nametableName - table name
java.sql.SQLException
protected java.sql.ResultSet getTablesResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
boolean baseTablesOnly)
throws java.sql.SQLException
AbstractDatabase
getTablesResultSet in class AbstractDatabasemd - DatabaseMetaData objectschemaName - schema namebaseTablesOnly - If true, return only base tables, not catalogs or
views
java.sql.SQLException
public java.lang.String getTimeDiff(java.lang.String string1,
java.lang.String string2)
public java.lang.String getNowFunction()
Database
public java.lang.String getPlaceHolder(OneRowChange.ColumnSpec col,
java.lang.Object colValue,
java.lang.String typeDesc)
Database
getPlaceHolder in interface DatabasegetPlaceHolder in class AbstractDatabasepublic boolean nullsBoundDifferently(OneRowChange.ColumnSpec col)
Database
nullsBoundDifferently in interface DatabasenullsBoundDifferently in class AbstractDatabasepublic boolean nullsEverBoundDifferently()
Database
nullsEverBoundDifferently in interface DatabasenullsEverBoundDifferently in class AbstractDatabase
public java.lang.String prepareOptionSetStatement(java.lang.String optionName,
java.lang.String optionValue)
prepareOptionSetStatement in interface DatabaseprepareOptionSetStatement in class AbstractDatabaseoptionName - the option to be setoptionValue - the value to be used
AbstractDatabase.prepareOptionSetStatement(java.lang.String,
java.lang.String)
public void createTable(Table t,
boolean replace,
java.lang.String tableType)
throws java.sql.SQLException
createTable in interface DatabasecreateTable in class AbstractDatabaset - Table specificationreplace - If true, replace an existing tabletableType - table type to be used for tungsten catalog
tables
java.sql.SQLExceptionAbstractDatabase.createTable(com.continuent.tungsten.replicator.database.Table,
boolean, java.lang.String)protected boolean supportsPrimaryKeys(java.lang.String tableType)
protected boolean supportsCharset(java.lang.String tableType)
protected boolean supportsNotNull(java.lang.String tableType)
public java.lang.String getDatabaseObjectName(java.lang.String name)
getDatabaseObjectName in interface DatabasegetDatabaseObjectName in class AbstractDatabasename - unquoted database object name
AbstractDatabase.getDatabaseObjectName(java.lang.String)
public SqlOperationMatcher getSqlNameMatcher()
throws ReplicatorException
getSqlNameMatcher in interface DatabasegetSqlNameMatcher in class AbstractDatabaseReplicatorExceptionAbstractDatabase.getSqlNameMatcher()public CsvWriter getCsvWriter(java.io.BufferedWriter writer)
writer - A buffered writer to receive CSV output
Database.getCsvWriter(java.io.BufferedWriter)public boolean supportsUserManagement()
supportsUserManagement in interface DatabasesupportsUserManagement in class AbstractDatabaseAbstractDatabase.supportsUserManagement()
public void createUser(User user)
throws java.sql.SQLException
createUser in interface DatabasecreateUser in class AbstractDatabaseuser - User definition
java.sql.SQLExceptionAbstractDatabase.createUser(com.continuent.tungsten.replicator.database.User)
public void dropUser(User user,
boolean ignore)
throws java.sql.SQLException
dropUser in interface DatabasedropUser in class AbstractDatabaseuser - User definitionignore - If true, ignore error
java.sql.SQLExceptionAbstractDatabase.dropUser(com.continuent.tungsten.replicator.database.User,
boolean)
public java.util.List<Session> listSessions()
throws java.sql.SQLException
listSessions in interface DatabaselistSessions in class AbstractDatabasejava.sql.SQLExceptionAbstractDatabase.listSessions()
public void kill(Session session)
throws java.sql.SQLException,
ReplicatorException
kill in interface Databasekill in class AbstractDatabasejava.sql.SQLException
ReplicatorExceptionAbstractDatabase.kill(com.continuent.tungsten.replicator.database.Session)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||