|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectliquibase.database.AbstractDatabase
public abstract class AbstractDatabase
AbstractDatabase is extended by all supported databases as a facade to the underlying database. The physical connection can be retrieved from the AbstractDatabase implementation, as well as any database-specific characteristics such as the datatype for "boolean" fields.
| Field Summary | |
|---|---|
protected java.lang.String |
currentDateTimeFunction
|
protected static java.util.logging.Logger |
log
|
| Constructor Summary | |
|---|---|
protected |
AbstractDatabase()
|
| Method Summary | |
|---|---|
protected boolean |
canCreateChangeLogTable()
|
void |
checkDatabaseChangeLogLockTable()
This method will check the database ChangeLogLock table used to keep track of if a machine is updating the database. |
void |
checkDatabaseChangeLogTable()
This method will check the database ChangeLog table used to keep track of the changes in the file. |
void |
close()
|
void |
commit()
|
java.lang.Object |
convertDatabaseValueToJavaObject(java.lang.Object defaultValue,
int dataType,
int columnSize,
int decimalDigits)
|
java.lang.String |
convertJavaObjectToString(java.lang.Object value)
|
java.lang.String |
convertRequestedSchemaToCatalog(java.lang.String requestedSchema)
|
java.lang.String |
convertRequestedSchemaToSchema(java.lang.String requestedSchema)
|
protected java.lang.Object |
convertToCorrectJavaType(java.lang.String value,
int dataType,
int columnSize,
int decimalDigits)
|
abstract DatabaseSnapshot |
createDatabaseSnapshot(java.lang.String schema,
java.util.Set<DiffStatusListener> statusListeners)
|
SqlStatement |
createFindSequencesSQL(java.lang.String schema)
|
boolean |
doesChangeLogLockTableExist()
|
boolean |
doesChangeLogTableExist()
|
boolean |
doesTagExist(java.lang.String tag)
|
void |
dropDatabaseObjects(java.lang.String schema)
Drops all objects owned by the connected user. |
boolean |
equals(java.lang.Object o)
|
java.lang.String |
escapeColumnName(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String columnName)
Escapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e. |
java.lang.String |
escapeColumnNameList(java.lang.String columnNames)
Escapes a list of column names in a database-dependent manner so reserved words can be used as a column name (i.e. |
java.lang.String |
escapeConstraintName(java.lang.String constraintName)
|
java.lang.String |
escapeIndexName(java.lang.String schemaName,
java.lang.String indexName)
|
java.lang.String |
escapeSequenceName(java.lang.String schemaName,
java.lang.String sequenceName)
|
java.lang.String |
escapeStringForDatabase(java.lang.String string)
|
java.lang.String |
escapeTableName(java.lang.String schemaName,
java.lang.String tableName)
Escapes the table name in a database-dependent manner so reserved words can be used as a table name (i.e. |
java.lang.String |
escapeViewName(java.lang.String schemaName,
java.lang.String viewName)
|
java.lang.String |
generatePrimaryKeyName(java.lang.String tableName)
|
boolean |
getAutoCommitMode()
Auto-commit mode to run in |
java.lang.String |
getAutoIncrementClause()
Returns database-specific auto-increment DDL clause. |
java.lang.String |
getBigIntType()
|
java.lang.String |
getCharType()
Returns the actual database-specific data type to use for a "char" column. |
java.lang.String |
getColumnType(ColumnConfig columnConfig)
|
java.lang.String |
getColumnType(java.lang.String columnType,
java.lang.Boolean autoIncrement)
Returns the database-specific datatype for the given column configuration. |
java.lang.String |
getConcatSql(java.lang.String... values)
Returns SQL to concat the passed values. |
DatabaseConnection |
getConnection()
|
java.lang.String |
getConnectionURL()
|
java.lang.String |
getConnectionUsername()
|
protected SqlStatement |
getCreateChangeLogLockSQL()
|
protected SqlStatement |
getCreateChangeLogSQL()
|
java.lang.String |
getDatabaseChangeLogLockTableName()
|
java.lang.String |
getDatabaseChangeLogTableName()
|
int |
getDatabaseMajorVersion()
|
int |
getDatabaseMinorVersion()
|
java.lang.String |
getDatabaseProductName()
Returns the name of the database product according to the underlying database. |
java.lang.String |
getDatabaseProductName(java.sql.Connection conn)
|
java.lang.String |
getDatabaseProductVersion()
|
int |
getDatabaseType(int type)
|
java.lang.String |
getDateLiteral(java.sql.Date date)
|
java.lang.String |
getDateLiteral(java.util.Date date)
|
java.lang.String |
getDateLiteral(java.lang.String isoDate)
Return a date literal with the same value as a string formatted using ISO 8601. |
java.lang.String |
getDateLiteral(java.sql.Time date)
|
java.lang.String |
getDateLiteral(java.sql.Timestamp date)
|
java.lang.String |
getDateType()
Returns the actual database-specific data type to use a "date" (no time information) column. |
java.lang.String |
getDefaultCatalogName()
|
protected java.lang.String |
getDefaultDatabaseSchemaName()
|
java.lang.String |
getDefaultSchemaName()
|
java.lang.String |
getDoubleType()
Returns the actual database-specific data type to use for a "double" column. |
java.lang.String |
getDriverName()
|
java.lang.String |
getFalseBooleanValue()
The database-specific value to use for "false" "boolean" columns. |
java.lang.String |
getFloatType()
Returns the actual database-specific data type to use for a "float" column. |
java.lang.String |
getIntType()
Returns the actual database-specific data type to use for a "int" column. |
JdbcTemplate |
getJdbcTemplate()
|
java.lang.String |
getLineComment()
Returns database-specific line comment string. |
java.lang.String |
getObjectEscapeCharacter()
|
RanChangeSet |
getRanChangeSet(ChangeSet changeSet)
|
java.util.List<RanChangeSet> |
getRanChangeSetList()
Returns the ChangeSets that have been run against the current database. |
java.util.Date |
getRanDate(ChangeSet changeSet)
|
ChangeSet.RunStatus |
getRunStatus(ChangeSet changeSet)
Returns the run status for the given ChangeSet |
SqlStatement |
getSelectChangeLogLockSQL()
|
protected java.util.Set<java.lang.String> |
getSystemTablesAndViews()
Returns system (undroppable) tables and views. |
java.lang.String |
getTimeType()
Returns the actual database-specific data type to use a "time" column. |
java.lang.String |
getTinyIntType()
Returns the actual database-specific data type to use for a "tinyint" column. |
java.lang.String |
getTrueBooleanValue()
The database-specific value to use for "true" "boolean" columns. |
java.lang.String |
getVarcharType()
Returns the actual database-specific data type to use for a "varchar" column. |
java.lang.String |
getViewDefinition(java.lang.String schemaName,
java.lang.String viewName)
|
SqlStatement |
getViewDefinitionSql(java.lang.String schemaName,
java.lang.String viewName)
|
int |
hashCode()
|
boolean |
isAutoCommit()
|
boolean |
isColumnAutoIncrement(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String columnName)
|
protected boolean |
isDateOnly(java.lang.String isoDate)
|
protected boolean |
isDateTime(java.lang.String isoDate)
|
boolean |
isLiquibaseTable(java.lang.String tableName)
|
boolean |
isLocalDatabase()
Default implementation, just look for "local" IPs |
boolean |
isSystemTable(java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String tableName)
|
boolean |
isSystemView(java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String viewName)
|
protected boolean |
isTimeOnly(java.lang.String isoDate)
|
void |
markChangeSetAsRan(ChangeSet changeSet)
After the change set has been ran against the database this method will update the change log table with the information. |
void |
markChangeSetAsReRan(ChangeSet changeSet)
|
protected java.util.Date |
parseDate(java.lang.String dateAsString)
|
void |
removeRanStatus(ChangeSet changeSet)
|
void |
rollback()
|
void |
setAutoCommit(boolean b)
|
void |
setConnection(java.sql.Connection conn)
|
void |
setConnection(DatabaseConnection conn)
|
void |
setCurrentDateTimeFunction(java.lang.String function)
|
void |
setDatabaseChangeLogLockTableName(java.lang.String tableName)
Set the table name of the change log lock to the given table name |
void |
setDatabaseChangeLogTableName(java.lang.String tableName)
Set the table name of the change log to the given table name |
void |
setDefaultSchemaName(java.lang.String schemaName)
|
void |
setJdbcTemplate(JdbcTemplate template)
|
boolean |
shouldQuoteValue(java.lang.String value)
|
boolean |
supportsAutoIncrement()
|
boolean |
supportsDDLInTransaction()
By default databases should support DDL within a transaction. |
boolean |
supportsRestrictForeignKeys()
|
boolean |
supportsSchemas()
|
boolean |
supportsSequences()
Does the database type support sequence. |
void |
tag(java.lang.String tagString)
Tags the database changelog with the given string. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface liquibase.database.Database |
|---|
getBlobType, getBooleanType, getClobType, getCurrencyType, getCurrentDateTimeFunction, getDateTimeType, getDefaultDriver, getProductName, getTypeName, getUUIDType, isCorrectDatabaseImplementation, supportsInitiallyDeferrableColumns, supportsTablespaces |
| Field Detail |
|---|
protected static final java.util.logging.Logger log
protected java.lang.String currentDateTimeFunction
| Constructor Detail |
|---|
protected AbstractDatabase()
| Method Detail |
|---|
public DatabaseConnection getConnection()
getConnection in interface Databasepublic void setConnection(java.sql.Connection conn)
setConnection in interface Databasepublic void setConnection(DatabaseConnection conn)
setConnection in interface Databasepublic boolean getAutoCommitMode()
getAutoCommitMode in interface Databasepublic boolean supportsDDLInTransaction()
supportsDDLInTransaction in interface Databasepublic java.lang.String getDatabaseProductName()
getDatabaseProductName in interface Database
public java.lang.String getDatabaseProductName(java.sql.Connection conn)
throws JDBCException
getDatabaseProductName in interface DatabaseJDBCException
public java.lang.String getDatabaseProductVersion()
throws JDBCException
getDatabaseProductVersion in interface DatabaseJDBCException
public int getDatabaseMajorVersion()
throws JDBCException
getDatabaseMajorVersion in interface DatabaseJDBCException
public int getDatabaseMinorVersion()
throws JDBCException
getDatabaseMinorVersion in interface DatabaseJDBCException
public java.lang.String getDriverName()
throws JDBCException
getDriverName in interface DatabaseJDBCException
public java.lang.String getConnectionURL()
throws JDBCException
getConnectionURL in interface DatabaseJDBCException
public java.lang.String getConnectionUsername()
throws JDBCException
getConnectionUsername in interface DatabaseJDBCException
public java.lang.String getDefaultCatalogName()
throws JDBCException
getDefaultCatalogName in interface DatabaseJDBCException
protected java.lang.String getDefaultDatabaseSchemaName()
throws JDBCException
JDBCExceptionpublic java.lang.String getDefaultSchemaName()
getDefaultSchemaName in interface Database
public void setDefaultSchemaName(java.lang.String schemaName)
throws JDBCException
setDefaultSchemaName in interface DatabaseJDBCExceptionprotected java.util.Set<java.lang.String> getSystemTablesAndViews()
public boolean supportsSequences()
supportsSequences in interface Databasepublic boolean supportsAutoIncrement()
supportsAutoIncrement in interface Databasepublic void setCurrentDateTimeFunction(java.lang.String function)
setCurrentDateTimeFunction in interface Database
public java.lang.String getColumnType(java.lang.String columnType,
java.lang.Boolean autoIncrement)
getColumnType in interface Databasepublic final java.lang.String getColumnType(ColumnConfig columnConfig)
public java.lang.String getFalseBooleanValue()
getFalseBooleanValue in interface Databasepublic java.lang.String getTrueBooleanValue()
getTrueBooleanValue in interface Databasepublic java.lang.String getDateLiteral(java.lang.String isoDate)
getDateLiteral in interface Databasepublic java.lang.String getDateLiteral(java.sql.Timestamp date)
getDateLiteral in interface Databasepublic java.lang.String getDateLiteral(java.sql.Date date)
getDateLiteral in interface Databasepublic java.lang.String getDateLiteral(java.sql.Time date)
getDateLiteral in interface Databasepublic java.lang.String getDateLiteral(java.util.Date date)
getDateLiteral in interface Database
protected java.util.Date parseDate(java.lang.String dateAsString)
throws DateParseException
DateParseExceptionprotected boolean isDateOnly(java.lang.String isoDate)
protected boolean isDateTime(java.lang.String isoDate)
protected boolean isTimeOnly(java.lang.String isoDate)
public java.lang.String getDateType()
getDateType in interface Databasepublic java.lang.String getTimeType()
getTimeType in interface Databasepublic java.lang.String getBigIntType()
getBigIntType in interface Databasepublic java.lang.String getCharType()
getCharType in interface Databasepublic java.lang.String getVarcharType()
getVarcharType in interface Databasepublic java.lang.String getFloatType()
getFloatType in interface Databasepublic java.lang.String getDoubleType()
getDoubleType in interface Databasepublic java.lang.String getIntType()
getIntType in interface Databasepublic java.lang.String getTinyIntType()
getTinyIntType in interface Databasepublic java.lang.String getLineComment()
getLineComment in interface Databasepublic java.lang.String getAutoIncrementClause()
getAutoIncrementClause in interface Databasepublic java.lang.String getConcatSql(java.lang.String... values)
Database
getConcatSql in interface Databasepublic java.lang.String getDatabaseChangeLogTableName()
getDatabaseChangeLogTableName in interface DatabaseDatabase.getDatabaseChangeLogTableName()public java.lang.String getDatabaseChangeLogLockTableName()
getDatabaseChangeLogLockTableName in interface DatabaseDatabase.getDatabaseChangeLogLockTableName()public void setDatabaseChangeLogTableName(java.lang.String tableName)
Database
setDatabaseChangeLogTableName in interface DatabaseDatabase.setDatabaseChangeLogTableName(java.lang.String)public void setDatabaseChangeLogLockTableName(java.lang.String tableName)
Database
setDatabaseChangeLogLockTableName in interface DatabaseDatabase.setDatabaseChangeLogLockTableName(java.lang.String)protected SqlStatement getCreateChangeLogLockSQL()
protected SqlStatement getCreateChangeLogSQL()
public SqlStatement getSelectChangeLogLockSQL()
throws JDBCException
getSelectChangeLogLockSQL in interface DatabaseJDBCException
public boolean doesChangeLogTableExist()
throws JDBCException
doesChangeLogTableExist in interface DatabaseJDBCException
public void checkDatabaseChangeLogTable()
throws JDBCException
checkDatabaseChangeLogTable in interface DatabaseJDBCException
protected boolean canCreateChangeLogTable()
throws JDBCException
JDBCException
public boolean doesChangeLogLockTableExist()
throws JDBCException
doesChangeLogLockTableExist in interface DatabaseJDBCException
public void checkDatabaseChangeLogLockTable()
throws JDBCException
checkDatabaseChangeLogLockTable in interface DatabaseJDBCException
public void dropDatabaseObjects(java.lang.String schema)
throws JDBCException
dropDatabaseObjects in interface Databaseschema -
JDBCException
public boolean isSystemTable(java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String tableName)
isSystemTable in interface Database
public boolean isSystemView(java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String viewName)
isSystemView in interface Databasepublic boolean isLiquibaseTable(java.lang.String tableName)
isLiquibaseTable in interface Database
public void tag(java.lang.String tagString)
throws JDBCException
tag in interface DatabaseJDBCException
public SqlStatement createFindSequencesSQL(java.lang.String schema)
throws JDBCException
createFindSequencesSQL in interface DatabaseJDBCException
public boolean doesTagExist(java.lang.String tag)
throws JDBCException
doesTagExist in interface DatabaseJDBCExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean shouldQuoteValue(java.lang.String value)
shouldQuoteValue in interface Database
public java.lang.String getViewDefinition(java.lang.String schemaName,
java.lang.String viewName)
throws JDBCException
getViewDefinition in interface DatabaseJDBCException
public SqlStatement getViewDefinitionSql(java.lang.String schemaName,
java.lang.String viewName)
throws JDBCException
JDBCExceptionpublic int getDatabaseType(int type)
getDatabaseType in interface Database
public java.lang.Object convertDatabaseValueToJavaObject(java.lang.Object defaultValue,
int dataType,
int columnSize,
int decimalDigits)
throws java.text.ParseException
convertDatabaseValueToJavaObject in interface Databasejava.text.ParseException
protected java.lang.Object convertToCorrectJavaType(java.lang.String value,
int dataType,
int columnSize,
int decimalDigits)
throws java.text.ParseException
java.text.ParseExceptionpublic java.lang.String convertJavaObjectToString(java.lang.Object value)
convertJavaObjectToString in interface Database
public java.lang.String escapeTableName(java.lang.String schemaName,
java.lang.String tableName)
Database
escapeTableName in interface Databasepublic java.lang.String getObjectEscapeCharacter()
public java.lang.String escapeIndexName(java.lang.String schemaName,
java.lang.String indexName)
escapeIndexName in interface Database
public java.lang.String escapeSequenceName(java.lang.String schemaName,
java.lang.String sequenceName)
escapeSequenceName in interface Databasepublic java.lang.String escapeConstraintName(java.lang.String constraintName)
escapeConstraintName in interface Database
public java.lang.String escapeColumnName(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String columnName)
Database
escapeColumnName in interface DatabasecolumnName - column name
public java.lang.String escapeColumnNameList(java.lang.String columnNames)
Database
escapeColumnNameList in interface DatabasecolumnNames - list of column names
public java.lang.String convertRequestedSchemaToCatalog(java.lang.String requestedSchema)
throws JDBCException
convertRequestedSchemaToCatalog in interface DatabaseJDBCException
public java.lang.String convertRequestedSchemaToSchema(java.lang.String requestedSchema)
throws JDBCException
convertRequestedSchemaToSchema in interface DatabaseJDBCExceptionpublic boolean supportsSchemas()
supportsSchemas in interface Databasepublic java.lang.String generatePrimaryKeyName(java.lang.String tableName)
generatePrimaryKeyName in interface Database
public java.lang.String escapeViewName(java.lang.String schemaName,
java.lang.String viewName)
escapeViewName in interface Database
public boolean isColumnAutoIncrement(java.lang.String schemaName,
java.lang.String tableName,
java.lang.String columnName)
throws java.sql.SQLException,
JDBCException
isColumnAutoIncrement in interface Databasejava.sql.SQLException
JDBCException
public ChangeSet.RunStatus getRunStatus(ChangeSet changeSet)
throws JDBCException,
DatabaseHistoryException
getRunStatus in interface DatabaseJDBCException
DatabaseHistoryException
public RanChangeSet getRanChangeSet(ChangeSet changeSet)
throws JDBCException,
DatabaseHistoryException
getRanChangeSet in interface DatabaseJDBCException
DatabaseHistoryException
public java.util.List<RanChangeSet> getRanChangeSetList()
throws JDBCException
getRanChangeSetList in interface DatabaseJDBCException
public java.util.Date getRanDate(ChangeSet changeSet)
throws JDBCException,
DatabaseHistoryException
getRanDate in interface DatabaseJDBCException
DatabaseHistoryException
public void markChangeSetAsRan(ChangeSet changeSet)
throws JDBCException
markChangeSetAsRan in interface DatabaseJDBCException
public void markChangeSetAsReRan(ChangeSet changeSet)
throws JDBCException
markChangeSetAsReRan in interface DatabaseJDBCException
public void removeRanStatus(ChangeSet changeSet)
throws JDBCException
removeRanStatus in interface DatabaseJDBCExceptionpublic java.lang.String escapeStringForDatabase(java.lang.String string)
escapeStringForDatabase in interface Database
public void commit()
throws JDBCException
commit in interface DatabaseJDBCException
public void rollback()
throws JDBCException
rollback in interface DatabaseJDBCExceptionpublic JdbcTemplate getJdbcTemplate()
getJdbcTemplate in interface Databasepublic void setJdbcTemplate(JdbcTemplate template)
setJdbcTemplate in interface Databasepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
public void close()
throws JDBCException
close in interface DatabaseJDBCException
public abstract DatabaseSnapshot createDatabaseSnapshot(java.lang.String schema,
java.util.Set<DiffStatusListener> statusListeners)
throws JDBCException
createDatabaseSnapshot in interface DatabaseJDBCExceptionpublic boolean supportsRestrictForeignKeys()
supportsRestrictForeignKeys in interface Database
public boolean isAutoCommit()
throws JDBCException
isAutoCommit in interface DatabaseJDBCException
public void setAutoCommit(boolean b)
throws JDBCException
setAutoCommit in interface DatabaseJDBCException
public boolean isLocalDatabase()
throws JDBCException
isLocalDatabase in interface DatabaseJDBCException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||