|
||||||||||
| 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.DrizzleDatabase
public class DrizzleDatabase
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 | |
|---|---|
DrizzleDatabase()
|
|
| 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 Drizzle 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)
Creates a table using the supplied table definition. |
void |
dropSchema(java.lang.String schema)
Drops the named schema. |
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 |
getNowFunction()
getNowFunction returns the database-specific way to get current date and time from the database. |
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 |
setSessionVariable(java.lang.String name,
java.lang.String value)
Sets a variable on the current session using MySQL SET command. |
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 |
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. |
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, createTable, createUser, delete, disconnect, dropTable, dropTungstenCatalog, dropUser, execute, executeUpdate, findTable, findTable, findTable, getBlobAsBytes, getConnection, getDatabaseMetaData, getDatabaseObjectName, getPlaceHolder, getReservedWords, getTables, getType, insert, isPrivileged, javaSQLTypeToNativeType, kill, listSessions, nativeTypeToJavaSQLType, nullsBoundDifferently, nullsEverBoundDifferently, prepareOptionSetStatement, prepareStatement, replace, rollback, setAutoCommit, setPassword, setPrivileged, setUrl, setUser, supportsNativeSlaveSync, supportsUserManagement, syncNativeSlave, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DrizzleDatabase()
throws java.sql.SQLException
java.sql.SQLException| Method Detail |
|---|
public SqlOperationMatcher getSqlNameMatcher()
throws ReplicatorException
getSqlNameMatcher in interface DatabasegetSqlNameMatcher in class AbstractDatabaseReplicatorExceptionAbstractDatabase.getSqlNameMatcher()
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
AbstractDatabase
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 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(String, 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(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.SQLExceptionpublic java.lang.String getNowFunction()
Database
public java.lang.String getTimeDiff(java.lang.String string1,
java.lang.String string2)
public CsvWriter getCsvWriter(java.io.BufferedWriter writer)
writer - A buffered writer to receive CSV output
Database.getCsvWriter(java.io.BufferedWriter)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||