|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Database
Defines the contract for a driver that implements database-specific SQL operations. There is an implementation of this interface for each DBMS implementation.
| Field Summary | |
|---|---|
static java.lang.String |
MYSQL
String to denote MySQL DBMS dialect in metadata. |
static java.lang.String |
ORACLE
String to denote Oracle dialect in metadata. |
static java.lang.String |
POSTGRESQL
String to denote PostgreSQL dialect in metadata. |
static java.lang.String |
UNKNOWN
String to denote PostgreSQL dialect in metadata. |
| Method Summary | |
|---|---|
void |
close()
Closes the instance and frees all resources. |
void |
commit()
Commit the current transaction. |
void |
connect()
Connects to the database. |
void |
connect(boolean binlog)
Connects to the database. |
void |
consistencyCheck(Table ct,
ConsistencyCheck cc)
Runs consistency check transaction |
void |
consistencyCheck(Table ct,
ConsistencyCheck cc,
java.lang.String masterCrc,
int masterCnt)
Runs consistency check transaction: a.) If masterCrc==null - normal (master side) consistency check is executed, which is expected to be replicated to the slaves by replication. b.) If masterCrc!=null, then masterCrc and masterCnt are put into corresponding columns, while executed check's results are put into this_crc and this_cnt columns. |
void |
controlSessionLevelLogging(boolean suppressed)
Sets session-level logging of updates. |
void |
createSchema(java.lang.String schema)
Creates the named schema. |
java.sql.Statement |
createStatement()
Generate a JDBC statement. |
void |
createTable(Table table,
boolean replace)
Creates a table using the supplied table definition. |
void |
createTable(Table table,
boolean replace,
java.lang.String tungstenTableType)
Creates a table using the supplied table definition and the provided table type. |
void |
createTable(Table table,
boolean replace,
java.lang.String tungstenSchema,
java.lang.String tungstenTableType)
|
void |
createTable(Table hbTable,
boolean b,
java.lang.String schema,
java.lang.String tableType,
java.lang.String serviceName)
|
void |
createUser(User user)
Creates a user. |
int |
delete(Table table,
boolean allRows)
Deletes a row in a table. |
void |
disconnect()
Disconnects from the database. |
void |
dropSchema(java.lang.String schema)
Drops the named schema. |
void |
dropTable(Table table)
Drops an existing table. |
void |
dropTungstenCatalog(java.lang.String schemaName,
java.lang.String tungstenTableType,
java.lang.String serviceName)
dropTungstenCatalog removes Tungsten catalog. |
void |
dropUser(User user,
boolean ignore)
Deletes a user. |
void |
execute(java.lang.String SQL)
Executes a SQL request. |
void |
executeUpdate(java.lang.String SQL)
Executes a SQL request containing an update. |
Table |
findTable(int tableID)
Return the Table with all its current accompanying Columns that matches tableID. |
Table |
findTable(int tableID,
java.lang.String scn)
Return the Table with all its accompanying Columns at the provided scn that matches tableID. |
Table |
findTable(java.lang.String schemaName,
java.lang.String tableName)
Return the Table with all its accompanying Columns. |
byte[] |
getBlobAsBytes(java.sql.ResultSet resultSet,
int column)
Fetches the given column as a byte[] array. |
java.sql.ResultSet |
getColumnsResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
Returns a result set containing columns for a specific table. |
java.sql.Connection |
getConnection()
Returns the database connection |
java.lang.String |
getControlTimestampQuery(java.lang.Long timestamp)
Returns a query that can be used to set the timestamp. |
CsvWriter |
getCsvWriter(java.io.BufferedWriter writer)
Returns a properly configured CsvWriter to generate CSV according to the preferred conventions of this DBMS type. |
java.sql.DatabaseMetaData |
getDatabaseMetaData()
Returns JDBC DatabaseMetadata for the current connection. |
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. |
java.util.ArrayList<java.lang.String> |
getReservedWords()
Returns a list of reserved words used by the DBMS, which cannot be used as table and column names. Words are expected to be upper case and applications checking with something similar to getReservedWords().contains(table.getName().toUpperCase()). |
java.util.ArrayList<java.lang.String> |
getSchemas()
Returns a list of schemas available on the server. |
java.lang.String |
getSessionVariable(java.lang.String name)
Get session variable. |
SqlOperationMatcher |
getSqlNameMatcher()
Returns a SQL name matcher for this database type. |
java.util.ArrayList<Table> |
getTables(java.lang.String schema,
boolean baseTablesOnly)
Returns a list of tables available in the schema |
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. |
DBMS |
getType()
Returns the type of DBMS behind the interface |
java.lang.String |
getUseSchemaQuery(java.lang.String schema)
Returns a query that can be used to set the schema. |
int |
insert(Table table)
Inserts a row into a table. |
boolean |
isPrivileged()
Returns true if this account is a super user. |
int |
javaSQLTypeToNativeType(int javaSQLType)
Opposite of the above function. |
void |
kill(Session session)
Kills a particular session. |
java.util.List<Session> |
listSessions()
Lists user sessions in the DBMS server. |
int |
nativeTypeToJavaSQLType(int nativeType)
Databases have various column types usually identified by some vendor defined integer value. |
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. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String statement)
Generate a JDBC prepared statement. |
void |
replace(Table table)
Replaces a row in the table using the data supplied by the Table specification. |
void |
rollback()
Rollback the current transaction. |
void |
setAutoCommit(boolean autoCommit)
Toggles autocommit by calling Connection.setAutocommit(). |
void |
setPassword(java.lang.String password)
Sets the database password. |
void |
setPrivileged(boolean privileged)
Determines whether this connection has superuser privileges (e.g., SYSDBA or SUPER depending on the DBMS type). |
void |
setSessionVariable(java.lang.String name,
java.lang.String value)
Sets a session variable. |
void |
setUrl(java.lang.String url)
Sets the JDBC URL used for database connections. |
void |
setUser(java.lang.String user)
Sets the database user. |
boolean |
supportsControlSessionLevelLogging()
Returns true if this implementation allow clients to turn logging of SQL updates on and off at the session level. |
boolean |
supportsControlTimestamp()
Returns true if this implementation supports changing the timestamp value used by functions that return the current time. |
boolean |
supportsCreateDropSchema()
Returns true if this implementation supports schema create and drop operations. |
boolean |
supportsNativeSlaveSync()
Returns true if this implementation supports synchronization of native slave replication with Tungsten position. |
boolean |
supportsReplace()
Returns true if the implementation supports a SQL REPLACE command. |
boolean |
supportsSessionVariables()
Returns true if this implementation supports setting session variables. |
boolean |
supportsUseDefaultSchema()
Returns true if this implementation supports changing the default schema, for example via a "USE |
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. |
int |
update(Table table,
java.util.ArrayList<Column> whereClause,
java.util.ArrayList<Column> values)
Updates on or more rows in a table. |
void |
useDefaultSchema(java.lang.String schema)
Changes the default schema to the named schema. |
| Field Detail |
|---|
static final java.lang.String MYSQL
static final java.lang.String ORACLE
static final java.lang.String POSTGRESQL
static final java.lang.String UNKNOWN
| Method Detail |
|---|
DBMS getType()
SqlOperationMatcher getSqlNameMatcher()
throws ReplicatorException
ReplicatorExceptionvoid setUrl(java.lang.String url)
void setUser(java.lang.String user)
void setPassword(java.lang.String password)
void setPrivileged(boolean privileged)
privileged - If true this account is a superuserboolean isPrivileged()
void connect()
throws java.sql.SQLException
java.sql.SQLException
void connect(boolean binlog)
throws java.sql.SQLException
binlog - log connection updates.
java.sql.SQLExceptionvoid disconnect()
java.sql.DatabaseMetaData getDatabaseMetaData()
throws java.sql.SQLException
java.sql.SQLException
void createTable(Table table,
boolean replace)
throws java.sql.SQLException
table - Table specificationreplace - If true, replace an existing table
java.sql.SQLException
boolean supportsCreateDropSchema()
throws java.sql.SQLException
java.sql.SQLException
void createSchema(java.lang.String schema)
throws java.sql.SQLException
java.sql.SQLExceptionsupportsCreateDropSchema()
void dropSchema(java.lang.String schema)
throws java.sql.SQLException
java.sql.SQLExceptionsupportsCreateDropSchema()
boolean supportsUseDefaultSchema()
throws java.sql.SQLException
java.sql.SQLException
void useDefaultSchema(java.lang.String schema)
throws java.sql.SQLException
java.sql.SQLExceptionsupportsUseDefaultSchema()java.lang.String getUseSchemaQuery(java.lang.String schema)
supportsUseDefaultSchema()
boolean supportsControlSessionLevelLogging()
throws java.sql.SQLException
java.sql.SQLException
void controlSessionLevelLogging(boolean suppressed)
throws java.sql.SQLException
suppressed - If true, updates are not logged; otherwise logging is
turned on
java.sql.SQLExceptionboolean supportsNativeSlaveSync()
void syncNativeSlave(java.lang.String eventId)
throws java.sql.SQLException
eventId - Tungsten event ID containing native log coordinates
java.sql.SQLException
boolean supportsControlTimestamp()
throws java.sql.SQLException
java.sql.SQLException
boolean supportsSessionVariables()
throws java.sql.SQLException
java.sql.SQLException
void setSessionVariable(java.lang.String name,
java.lang.String value)
throws java.sql.SQLException
name - Name of the variable to setvalue - Value to set
java.sql.SQLException - Thrown if setting variable is unsuccessful
java.lang.String getSessionVariable(java.lang.String name)
throws java.sql.SQLException
name - Name of the variable to get
java.sql.SQLException - Thrown if getting variable is unsuccessfulboolean supportsUserManagement()
void createUser(User user)
throws java.sql.SQLException
user - User definition
java.sql.SQLException
void dropUser(User user,
boolean ignore)
throws java.sql.SQLException
user - User definitionignore - If true, ignore error
java.sql.SQLException
java.util.List<Session> listSessions()
throws java.sql.SQLException
java.sql.SQLException
void kill(Session session)
throws java.sql.SQLException,
ReplicatorException
java.sql.SQLException
ReplicatorException
Table findTable(int tableID)
throws java.sql.SQLException
java.sql.SQLException
Table findTable(int tableID,
java.lang.String scn)
throws java.sql.SQLException
tableID - the object which is looked forscn - when the object is search for
java.sql.SQLException - if an error occurs
Table findTable(java.lang.String schemaName,
java.lang.String tableName)
throws java.sql.SQLException
schemaName - name of schema containing the tabletableName - name of the table
java.sql.SQLException - if an error occursjava.lang.String getControlTimestampQuery(java.lang.Long timestamp)
timestamp - A Java time value consisting of milliseconds since
January 1, 1970 00:00:00 GMTsupportsControlTimestamp()
void execute(java.lang.String SQL)
throws java.sql.SQLException
java.sql.SQLException
void executeUpdate(java.lang.String SQL)
throws java.sql.SQLException
java.sql.SQLException
int insert(Table table)
throws java.sql.SQLException
table - Table instance containing column data
java.sql.SQLException
int update(Table table,
java.util.ArrayList<Column> whereClause,
java.util.ArrayList<Column> values)
throws java.sql.SQLException
table - Table instance to updatewhereClause - List of columns containing where clause values, which
are ANDedvalues - List of columns containing values to set for matching rows
java.sql.SQLExceptionboolean supportsReplace()
void replace(Table table)
throws java.sql.SQLException
table - Table definition with column data and primary key
java.sql.SQLExceptionsupportsReplace()
int delete(Table table,
boolean allRows)
throws java.sql.SQLException
table - Table specification with primary key; columns for the key
must be defined.allRows - flag indicating that all rows from the underlying table
should be deleted
java.sql.SQLException
java.sql.PreparedStatement prepareStatement(java.lang.String statement)
throws java.sql.SQLException
statement - SQL statement to prepare
java.sql.SQLException
java.sql.Statement createStatement()
throws java.sql.SQLException
java.sql.SQLException
void commit()
throws java.sql.SQLException
java.sql.SQLException
void rollback()
throws java.sql.SQLException
java.sql.SQLException
void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
java.sql.SQLException
java.lang.String getPlaceHolder(OneRowChange.ColumnSpec col,
java.lang.Object colValue,
java.lang.String typeDesc)
boolean nullsBoundDifferently(OneRowChange.ColumnSpec col)
boolean nullsEverBoundDifferently()
java.sql.Connection getConnection()
void dropTable(Table table)
void close()
int nativeTypeToJavaSQLType(int nativeType)
throws java.sql.SQLException
java.sql.SQLException
int javaSQLTypeToNativeType(int javaSQLType)
throws java.sql.SQLException
java.sql.SQLException
java.util.ArrayList<java.lang.String> getSchemas()
throws java.sql.SQLException
java.sql.SQLException
java.util.ArrayList<Table> getTables(java.lang.String schema,
boolean baseTablesOnly)
throws java.sql.SQLException
schema - Name of the schemabaseTablesOnly - If true, only return real tables and not catalogs
or views
java.sql.SQLException
java.sql.ResultSet getColumnsResultSet(java.sql.DatabaseMetaData md,
java.lang.String schemaName,
java.lang.String tableName)
throws java.sql.SQLException
md - DatabaseMetaData objectschemaName - schema nametableName - table name
java.sql.SQLException
void consistencyCheck(Table ct,
ConsistencyCheck cc)
throws java.sql.SQLException,
ConsistencyException
ct - consitency tablecc - ConsistencyCheck specification
java.sql.SQLException
ConsistencyException
void consistencyCheck(Table ct,
ConsistencyCheck cc,
java.lang.String masterCrc,
int masterCnt)
throws java.sql.SQLException,
ConsistencyException
ct - Consistency table.cc - ConsistencyCheck specification.masterCrc - CRC value of this check on the master.masterCnt - Count of rows of this check on the master.
java.sql.SQLException
ConsistencyExceptionjava.lang.String getNowFunction()
java.lang.String getTimeDiff(java.lang.String string1,
java.lang.String string2)
void createTable(Table table,
boolean replace,
java.lang.String tungstenTableType)
throws java.sql.SQLException
table - Table specificationreplace - If true, replace an existing tabletungstenTableType - table type to be used for tungsten catalog
tables
java.sql.SQLException
void createTable(Table table,
boolean replace,
java.lang.String tungstenSchema,
java.lang.String tungstenTableType)
throws java.sql.SQLException
java.sql.SQLException
void createTable(Table hbTable,
boolean b,
java.lang.String schema,
java.lang.String tableType,
java.lang.String serviceName)
throws java.sql.SQLException
java.sql.SQLException
java.lang.String prepareOptionSetStatement(java.lang.String optionName,
java.lang.String optionValue)
optionName - the option to be setoptionValue - the value to be used
byte[] getBlobAsBytes(java.sql.ResultSet resultSet,
int column)
throws java.sql.SQLException
resultSet - ResultSet which has this blob column.column - Index of the column to fetch value from.
java.sql.SQLException - As this method is operating on ResultSet, it might
throw a SQLException.java.lang.String getDatabaseObjectName(java.lang.String name)
name - unquoted database object name
CsvWriter getCsvWriter(java.io.BufferedWriter writer)
writer - A buffered writer to receive CSV output
java.util.ArrayList<java.lang.String> getReservedWords()
void dropTungstenCatalog(java.lang.String schemaName,
java.lang.String tungstenTableType,
java.lang.String serviceName)
throws java.sql.SQLException
schemaName - The schema name where Tungsten catalog is storedtungstenTableType - The type of table used to store Tungsten metadataserviceName - The service name for which the catalog has to be dropped
java.sql.SQLException - when an error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||