|
||||||||||
| 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 java.util.List<DatabaseFunction> |
databaseFunctions
|
protected java.math.BigInteger |
defaultAutoIncrementBy
|
protected java.math.BigInteger |
defaultAutoIncrementStartWith
|
| Fields inherited from interface liquibase.servicelocator.PrioritizedService |
|---|
PRIORITY_DATABASE, PRIORITY_DEFAULT |
| 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(boolean updateExistingNullChecksums,
DatabaseChangeLog databaseChangeLog,
java.lang.String... contexts)
This method will check the database ChangeLog table used to keep track of the changes in the file. |
void |
close()
|
void |
commit()
|
java.lang.String |
convertRequestedSchemaToCatalog(java.lang.String requestedSchema)
|
java.lang.String |
convertRequestedSchemaToSchema(java.lang.String requestedSchema)
|
boolean |
disableForeignKeyChecks()
|
boolean |
doesTagExist(java.lang.String tag)
|
void |
dropDatabaseObjects(java.lang.String schema)
Drops all objects owned by the connected user. |
void |
enableForeignKeyChecks()
|
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 |
escapeDatabaseObject(java.lang.String objectName)
|
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)
|
void |
execute(SqlStatement[] statements,
java.util.List<SqlVisitor> sqlVisitors)
|
void |
executeRollbackStatements(Change change,
java.util.List<SqlVisitor> sqlVisitors)
|
void |
executeStatements(Change change,
DatabaseChangeLog changeLog,
java.util.List<SqlVisitor> sqlVisitors)
|
protected boolean |
generateAutoIncrementBy(java.math.BigInteger incrementBy)
|
protected boolean |
generateAutoIncrementStartWith(java.math.BigInteger startWith)
|
java.lang.String |
generatePrimaryKeyName(java.lang.String tableName)
|
boolean |
getAutoCommitMode()
Auto-commit mode to run in |
protected java.lang.String |
getAutoIncrementByClause()
|
protected java.lang.String |
getAutoIncrementClause()
|
java.lang.String |
getAutoIncrementClause(java.math.BigInteger startWith,
java.math.BigInteger incrementBy)
Returns database-specific auto-increment DDL clause. |
protected java.lang.String |
getAutoIncrementClosing()
|
protected java.lang.String |
getAutoIncrementOpening()
|
protected java.lang.String |
getAutoIncrementStartWithClause()
|
java.lang.String |
getConcatSql(java.lang.String... values)
Returns SQL to concat the passed values. |
DatabaseConnection |
getConnection()
|
DatabaseObject[] |
getContainingObjects()
|
java.lang.String |
getDatabaseChangeLogLockTableName()
|
java.lang.String |
getDatabaseChangeLogTableName()
|
java.util.List<DatabaseFunction> |
getDatabaseFunctions()
Returns list of database native functions |
int |
getDatabaseMajorVersion()
|
int |
getDatabaseMinorVersion()
|
java.lang.String |
getDatabaseProductName()
Returns the name of the database product according to the underlying database. |
java.lang.String |
getDatabaseProductVersion()
|
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 |
getDateTimeLiteral(java.sql.Timestamp date)
|
java.lang.String |
getDefaultCatalogName()
|
protected java.lang.String |
getDefaultDatabaseSchemaName()
|
java.lang.String |
getDefaultSchemaName()
|
java.lang.String |
getLineComment()
Returns database-specific line comment string. |
java.lang.String |
getLiquibaseSchemaName()
|
int |
getNextChangeSetSequenceValue()
|
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 |
protected java.util.Set<java.lang.String> |
getSystemTablesAndViews()
Returns system (undroppable) tables and views. |
Table |
getTable(java.lang.String schemaName,
java.lang.String tableName)
|
java.lang.String |
getTimeLiteral(java.sql.Time date)
|
java.lang.String |
getViewDefinition(java.lang.String schemaName,
java.lang.String viewName)
|
boolean |
hasDatabaseChangeLogLockTable()
|
boolean |
hasDatabaseChangeLogTable()
|
int |
hashCode()
|
boolean |
isAutoCommit()
|
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 |
isReservedWord(java.lang.String string)
|
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 |
markChangeSetExecStatus(ChangeSet changeSet,
ChangeSet.ExecType execType)
After the change set has been ran against the database this method will update the change log table with the information. |
java.util.Date |
parseDate(java.lang.String dateAsString)
|
void |
removeRanStatus(ChangeSet changeSet)
|
boolean |
requiresPassword()
|
boolean |
requiresUsername()
|
void |
reset()
|
void |
rollback()
|
void |
saveRollbackStatement(Change change,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
|
void |
saveStatements(Change change,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
|
void |
setAutoCommit(boolean b)
|
void |
setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)
|
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)
|
boolean |
shouldQuoteValue(java.lang.String value)
|
boolean |
supportsAutoIncrement()
|
boolean |
supportsDDLInTransaction()
By default databases should support DDL within a transaction. |
boolean |
supportsDropTableCascadeConstraints()
|
boolean |
supportsForeignKeyDisable()
|
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 |
|---|
getCurrentDateTimeFunction, getDefaultDriver, getTypeName, isCorrectDatabaseImplementation, supportsInitiallyDeferrableColumns, supportsTablespaces |
| Methods inherited from interface liquibase.servicelocator.PrioritizedService |
|---|
getPriority |
| Field Detail |
|---|
protected java.lang.String currentDateTimeFunction
protected java.util.List<DatabaseFunction> databaseFunctions
protected java.math.BigInteger defaultAutoIncrementStartWith
protected java.math.BigInteger defaultAutoIncrementBy
| Constructor Detail |
|---|
protected AbstractDatabase()
| Method Detail |
|---|
public boolean requiresPassword()
requiresPassword in interface Databasepublic boolean requiresUsername()
requiresUsername in interface Databasepublic DatabaseObject[] getContainingObjects()
getContainingObjects in interface DatabaseObjectpublic DatabaseConnection getConnection()
getConnection 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 getDatabaseProductVersion()
throws DatabaseException
getDatabaseProductVersion in interface DatabaseDatabaseException
public int getDatabaseMajorVersion()
throws DatabaseException
getDatabaseMajorVersion in interface DatabaseDatabaseException
public int getDatabaseMinorVersion()
throws DatabaseException
getDatabaseMinorVersion in interface DatabaseDatabaseException
public java.lang.String getDefaultCatalogName()
throws DatabaseException
getDefaultCatalogName in interface DatabaseDatabaseException
protected java.lang.String getDefaultDatabaseSchemaName()
throws DatabaseException
DatabaseExceptionpublic java.lang.String getDefaultSchemaName()
getDefaultSchemaName in interface Database
public void setDefaultSchemaName(java.lang.String schemaName)
throws DatabaseException
setDefaultSchemaName in interface DatabaseDatabaseExceptionprotected 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 Databasepublic java.lang.String getDateLiteral(java.lang.String isoDate)
getDateLiteral in interface Databasepublic java.lang.String getDateTimeLiteral(java.sql.Timestamp date)
getDateTimeLiteral in interface Databasepublic java.lang.String getDateLiteral(java.sql.Date date)
getDateLiteral in interface Databasepublic java.lang.String getTimeLiteral(java.sql.Time date)
getTimeLiteral in interface Databasepublic java.lang.String getDateLiteral(java.util.Date date)
getDateLiteral in interface Database
public java.util.Date parseDate(java.lang.String dateAsString)
throws DateParseException
parseDate in interface DatabaseDateParseExceptionprotected boolean isDateOnly(java.lang.String isoDate)
protected boolean isDateTime(java.lang.String isoDate)
protected boolean isTimeOnly(java.lang.String isoDate)
public java.lang.String getLineComment()
getLineComment in interface Database
public java.lang.String getAutoIncrementClause(java.math.BigInteger startWith,
java.math.BigInteger incrementBy)
getAutoIncrementClause in interface Databaseprotected java.lang.String getAutoIncrementClause()
protected boolean generateAutoIncrementStartWith(java.math.BigInteger startWith)
protected boolean generateAutoIncrementBy(java.math.BigInteger incrementBy)
protected java.lang.String getAutoIncrementOpening()
protected java.lang.String getAutoIncrementClosing()
protected java.lang.String getAutoIncrementStartWithClause()
protected java.lang.String getAutoIncrementByClause()
public 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)
public void checkDatabaseChangeLogTable(boolean updateExistingNullChecksums,
DatabaseChangeLog databaseChangeLog,
java.lang.String... contexts)
throws DatabaseException
checkDatabaseChangeLogTable in interface DatabaseupdateExistingNullChecksums - contexts -
DatabaseException
protected boolean canCreateChangeLogTable()
throws DatabaseException
DatabaseExceptionpublic void setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)
setCanCacheLiquibaseTableInfo in interface Database
public boolean hasDatabaseChangeLogTable()
throws DatabaseException
hasDatabaseChangeLogTable in interface DatabaseDatabaseException
public boolean hasDatabaseChangeLogLockTable()
throws DatabaseException
hasDatabaseChangeLogLockTable in interface DatabaseDatabaseExceptionpublic java.lang.String getLiquibaseSchemaName()
getLiquibaseSchemaName in interface Database
public void checkDatabaseChangeLogLockTable()
throws DatabaseException
checkDatabaseChangeLogLockTable in interface DatabaseDatabaseExceptionpublic boolean isReservedWord(java.lang.String string)
isReservedWord in interface Database
public void dropDatabaseObjects(java.lang.String schema)
throws DatabaseException
dropDatabaseObjects in interface Databaseschema -
DatabaseExceptionpublic boolean supportsDropTableCascadeConstraints()
supportsDropTableCascadeConstraints in interface Database
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 DatabaseException
tag in interface DatabaseDatabaseException
public boolean doesTagExist(java.lang.String tag)
throws DatabaseException
doesTagExist in interface DatabaseDatabaseExceptionpublic 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 DatabaseException
getViewDefinition in interface DatabaseDatabaseException
public java.lang.String escapeTableName(java.lang.String schemaName,
java.lang.String tableName)
Database
escapeTableName in interface Databasepublic java.lang.String escapeDatabaseObject(java.lang.String objectName)
escapeDatabaseObject in interface Database
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 DatabaseException
convertRequestedSchemaToCatalog in interface DatabaseDatabaseException
public java.lang.String convertRequestedSchemaToSchema(java.lang.String requestedSchema)
throws DatabaseException
convertRequestedSchemaToSchema in interface DatabaseDatabaseExceptionpublic 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 ChangeSet.RunStatus getRunStatus(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
getRunStatus in interface DatabaseDatabaseException
DatabaseHistoryException
public RanChangeSet getRanChangeSet(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
getRanChangeSet in interface DatabaseDatabaseException
DatabaseHistoryException
public java.util.List<RanChangeSet> getRanChangeSetList()
throws DatabaseException
getRanChangeSetList in interface DatabaseDatabaseException
public java.util.Date getRanDate(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
getRanDate in interface DatabaseDatabaseException
DatabaseHistoryException
public void markChangeSetExecStatus(ChangeSet changeSet,
ChangeSet.ExecType execType)
throws DatabaseException
markChangeSetExecStatus in interface DatabaseDatabaseException
public void removeRanStatus(ChangeSet changeSet)
throws DatabaseException
removeRanStatus in interface DatabaseDatabaseExceptionpublic java.lang.String escapeStringForDatabase(java.lang.String string)
escapeStringForDatabase in interface Database
public void commit()
throws DatabaseException
commit in interface DatabaseDatabaseException
public void rollback()
throws DatabaseException
rollback in interface DatabaseDatabaseExceptionpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
public void close()
throws DatabaseException
close in interface DatabaseDatabaseExceptionpublic boolean supportsRestrictForeignKeys()
supportsRestrictForeignKeys in interface Database
public boolean isAutoCommit()
throws DatabaseException
isAutoCommit in interface DatabaseDatabaseException
public void setAutoCommit(boolean b)
throws DatabaseException
setAutoCommit in interface DatabaseDatabaseException
public boolean isLocalDatabase()
throws DatabaseException
isLocalDatabase in interface DatabaseDatabaseException
public void executeStatements(Change change,
DatabaseChangeLog changeLog,
java.util.List<SqlVisitor> sqlVisitors)
throws LiquibaseException,
UnsupportedChangeException
executeStatements in interface DatabaseLiquibaseException
UnsupportedChangeException
public void execute(SqlStatement[] statements,
java.util.List<SqlVisitor> sqlVisitors)
throws LiquibaseException
execute in interface DatabaseLiquibaseException
public void saveStatements(Change change,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
throws java.io.IOException,
UnsupportedChangeException,
StatementNotSupportedOnDatabaseException,
LiquibaseException
saveStatements in interface Databasejava.io.IOException
UnsupportedChangeException
StatementNotSupportedOnDatabaseException
LiquibaseException
public void executeRollbackStatements(Change change,
java.util.List<SqlVisitor> sqlVisitors)
throws LiquibaseException,
UnsupportedChangeException,
RollbackImpossibleException
executeRollbackStatements in interface DatabaseLiquibaseException
UnsupportedChangeException
RollbackImpossibleException
public void saveRollbackStatement(Change change,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
throws java.io.IOException,
UnsupportedChangeException,
RollbackImpossibleException,
StatementNotSupportedOnDatabaseException,
LiquibaseException
saveRollbackStatement in interface Databasejava.io.IOException
UnsupportedChangeException
RollbackImpossibleException
StatementNotSupportedOnDatabaseException
LiquibaseException
public int getNextChangeSetSequenceValue()
throws LiquibaseException
getNextChangeSetSequenceValue in interface DatabaseLiquibaseException
public Table getTable(java.lang.String schemaName,
java.lang.String tableName)
throws DatabaseException
DatabaseExceptionpublic java.util.List<DatabaseFunction> getDatabaseFunctions()
Database
getDatabaseFunctions in interface Databasepublic void reset()
reset in interface Databasepublic boolean supportsForeignKeyDisable()
supportsForeignKeyDisable in interface Database
public boolean disableForeignKeyChecks()
throws DatabaseException
disableForeignKeyChecks in interface DatabaseDatabaseException
public void enableForeignKeyChecks()
throws DatabaseException
enableForeignKeyChecks in interface DatabaseDatabaseException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||