com.continuent.tungsten.replicator.database
Class DerbyDatabase

java.lang.Object
  extended by com.continuent.tungsten.replicator.database.AbstractDatabase
      extended by com.continuent.tungsten.replicator.database.DerbyDatabase
All Implemented Interfaces:
Database

public class DerbyDatabase
extends AbstractDatabase

Implements DBMS-specific operations for the Derby database.

Version:
1.0
Author:
Robert Hodges

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
DerbyDatabase()
          Create a new instance.
 
Method Summary
protected  java.lang.String columnToTypeString(Column c, java.lang.String tableType)
          Provide column specifications that work in Derby, which hews very closely to the SQL-92 standard.
 java.sql.ResultSet getColumnsResultSet(java.sql.DatabaseMetaData md, java.lang.String schemaName, java.lang.String tableName)
          This function should be implemented in concrete class.
 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.
 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.
 boolean supportsReplace()
          Derby does not support REPLACE.
 
Methods inherited from class com.continuent.tungsten.replicator.database.AbstractDatabase
close, commit, connect, connect, consistencyCheck, consistencyCheck, controlSessionLevelLogging, createSchema, createStatement, createTable, createTable, createTable, createTable, createUser, delete, disconnect, dropSchema, dropTable, dropTungstenCatalog, dropUser, execute, executeUpdate, findTable, findTable, findTable, getBlobAsBytes, getConnection, getControlTimestampQuery, getDatabaseMetaData, getDatabaseObjectName, getPlaceHolder, getReservedWords, getSessionVariable, getTables, getType, getUseSchemaQuery, insert, isPrivileged, javaSQLTypeToNativeType, kill, listSessions, nativeTypeToJavaSQLType, nullsBoundDifferently, nullsEverBoundDifferently, prepareOptionSetStatement, prepareStatement, replace, rollback, setAutoCommit, setPassword, setPrivileged, setSessionVariable, setUrl, setUser, supportsControlSessionLevelLogging, supportsControlTimestamp, supportsCreateDropSchema, supportsNativeSlaveSync, supportsSessionVariables, supportsUseDefaultSchema, supportsUserManagement, syncNativeSlave, update, useDefaultSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerbyDatabase

public DerbyDatabase()
Create a new instance.

Method Detail

getSqlNameMatcher

public SqlOperationMatcher getSqlNameMatcher()
                                      throws ReplicatorException
Returns a SQL name matcher for this database type. You can get a matcher without calling connect() first.

Specified by:
getSqlNameMatcher in interface Database
Specified by:
getSqlNameMatcher in class AbstractDatabase
Throws:
ReplicatorException
See Also:
AbstractDatabase.getSqlNameMatcher()

columnToTypeString

protected java.lang.String columnToTypeString(Column c,
                                              java.lang.String tableType)
Provide column specifications that work in Derby, which hews very closely to the SQL-92 standard. Return a properly constructed type specification for the column. Concrete Database subclasses must implement at least this method if no others.

Specified by:
columnToTypeString in class AbstractDatabase
Parameters:
c - Column for which specification is required
Returns:
String containing specification
See Also:
AbstractDatabase.columnToTypeString(com.continuent.tungsten.replicator.database.Column, java.lang.String)

supportsReplace

public boolean supportsReplace()
Derby does not support REPLACE. Returns true if the implementation supports a SQL REPLACE command.

Specified by:
supportsReplace in interface Database
Overrides:
supportsReplace in class AbstractDatabase
See Also:
AbstractDatabase.supportsReplace()

getSchemas

public java.util.ArrayList<java.lang.String> getSchemas()
                                                 throws java.sql.SQLException
Description copied from interface: Database
Returns a list of schemas available on the server.

Returns:
list of available schemas
Throws:
java.sql.SQLException

getColumnsResultSet

public java.sql.ResultSet getColumnsResultSet(java.sql.DatabaseMetaData md,
                                              java.lang.String schemaName,
                                              java.lang.String tableName)
                                       throws java.sql.SQLException
Description copied from class: AbstractDatabase
This function should be implemented in concrete class.

Specified by:
getColumnsResultSet in interface Database
Specified by:
getColumnsResultSet in class AbstractDatabase
Parameters:
md - DatabaseMetaData object
schemaName - schema name
tableName - table name
Returns:
ResultSet as produced by DatabaseMetaData.getColumns() for a given schema and table
Throws:
java.sql.SQLException

getPrimaryKeyResultSet

protected java.sql.ResultSet getPrimaryKeyResultSet(java.sql.DatabaseMetaData md,
                                                    java.lang.String schemaName,
                                                    java.lang.String tableName)
                                             throws java.sql.SQLException
Description copied from class: AbstractDatabase
This function should be implemented in concrete class.

Specified by:
getPrimaryKeyResultSet in class AbstractDatabase
Parameters:
md - DatabaseMetaData object
schemaName - schema name
tableName - table name
Returns:
ResultSet as produced by DatabaseMetaData.getPrimaryKeys() for a given schema and table
Throws:
java.sql.SQLException

getTablesResultSet

protected java.sql.ResultSet getTablesResultSet(java.sql.DatabaseMetaData md,
                                                java.lang.String schemaName,
                                                boolean baseTablesOnly)
                                         throws java.sql.SQLException
Description copied from class: AbstractDatabase
This function should be implemented in concrete class.

Specified by:
getTablesResultSet in class AbstractDatabase
Parameters:
md - DatabaseMetaData object
schemaName - schema name
baseTablesOnly - If true, return only base tables, not catalogs or views
Returns:
ResultSet as produced by DatabaseMetaData.getTables() for a given schema
Throws:
java.sql.SQLException

getNowFunction

public java.lang.String getNowFunction()
Description copied from interface: Database
getNowFunction returns the database-specific way to get current date and time from the database.

Returns:
the name of the function to be called at the database level to get the current date and time

getTimeDiff

public 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. I, Scott, am not sure how to express the differences between two dates in derby in seconds. This function is currently only called by the time based "thl purge" command. For now, simply subtract the two dates.


getCsvWriter

public CsvWriter getCsvWriter(java.io.BufferedWriter writer)
Returns a properly configured CsvWriter to generate CSV according to the preferred conventions of this DBMS type.

Parameters:
writer - A buffered writer to receive CSV output
Returns:
A property configured CsvWriter instance
See Also:
Database.getCsvWriter(java.io.BufferedWriter)