|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dbmaintain.database.Database
public abstract class Database
Helper class that implements a number of common operations on a database schema. Operations that can be implemented using general JDBC or ANSI SQL constructs, are implemented in this base abstract class. Operations that are DBMS specific are abstract, and their implementation is left to DBMS specific subclasses.
Field Summary | |
---|---|
protected DatabaseConnection |
databaseConnection
|
protected IdentifierProcessor |
identifierProcessor
|
protected Set<String> |
schemaNames
|
Constructor Summary | |
---|---|
protected |
Database(DatabaseConnection databaseConnection,
IdentifierProcessor identifierProcessor)
|
Method Summary | |
---|---|
void |
disableReferentialConstraints()
Disables all referential constraints (e.g. foreign keys) on all table in the default schema |
abstract void |
disableReferentialConstraints(String schemaName)
Disables all referential constraints (e.g. foreign keys) on all table in the given schema |
void |
disableValueConstraints()
Disables all value constraints (e.g. not null) on all tables in the default schema |
abstract void |
disableValueConstraints(String schemaName)
Disables all value constraints (e.g. not null) on all tables in the given schema |
void |
dropMaterializedView(String viewName)
Removes the materialized view with the given name from the default schema Note: the view name is surrounded with quotes, making it case-sensitive. |
void |
dropMaterializedView(String schemaName,
String viewName)
Removes the materialized view with the given name from the given schema Note: the view name is surrounded with quotes, making it case-sensitive. |
void |
dropRule(String schemaName,
String ruleName)
Drops the rule with the given name from the given schema Note: the rule name is surrounded with quotes, making it case-sensitive. |
void |
dropSequence(String sequenceName)
Drops the sequence with the given name from the default schema Note: the sequence name is surrounded with quotes, making it case-sensitive. |
void |
dropSequence(String schemaName,
String sequenceName)
Drops the sequence with the given name from the given schema Note: the sequence name is surrounded with quotes, making it case-sensitive. |
void |
dropStoredProcedure(String storedProcedureName)
Drops the stored procedure with the given name from the default schema Note: the stored procedure name is surrounded with quotes, making it case-sensitive. |
void |
dropStoredProcedure(String schemaName,
String storedProcedureName)
Drops the stored procedure with the given name from the given schema Note: the stored procedure name is surrounded with quotes, making it case-sensitive. |
void |
dropSynonym(String synonymName)
Removes the synonym with the given name from the default schema Note: the synonym name is surrounded with quotes, making it case-sensitive. |
void |
dropSynonym(String schemaName,
String synonymName)
Removes the synonym with the given name from the given schema Note: the synonym name is surrounded with quotes, making it case-sensitive. |
void |
dropTable(String tableName)
Removes the table with the given name from the default schema. |
void |
dropTable(String schemaName,
String tableName)
Removes the table with the given name from the given schema. |
void |
dropTrigger(String triggerName)
Drops the trigger with the given name from the default schema Note: the trigger name is surrounded with quotes, making it case-sensitive. |
void |
dropTrigger(String schemaName,
String triggerName)
Drops the trigger with the given name from the given schema Note: the trigger name is surrounded with quotes, making it case-sensitive. |
void |
dropType(String typeName)
Drops the type with the given name from the default schema Note: the type name is surrounded with quotes, making it case-sensitive. |
void |
dropType(String schemaName,
String typeName)
Drops the type with the given name from the given schema Note: the type name is surrounded with quotes, making it case-sensitive. |
void |
dropView(String viewName)
Removes the view with the given name from the default schema Note: the view name is surrounded with quotes, making it case-sensitive. |
void |
dropView(String schemaName,
String viewName)
Removes the view with the given name from the given schema Note: the view name is surrounded with quotes, making it case-sensitive. |
Set<String> |
getColumnNames(String tableName)
Gets the names of all columns of the given table in the default schema. |
abstract Set<String> |
getColumnNames(String schemaName,
String tableName)
Gets the names of all columns of the given table. |
DatabaseInfo |
getDatabaseInfo()
|
String |
getDatabaseName()
|
DataSource |
getDataSource()
Gets the data source. |
String |
getDefaultSchemaName()
|
String |
getIdentifierQuoteString()
|
Set<String> |
getIdentityColumnNames(String tableName)
Gets the names of all identity columns of the given table in the default schema. |
Set<String> |
getIdentityColumnNames(String schemaName,
String tableName)
Gets the names of all identity columns of the given table in the given schema. |
String |
getLongDataType()
Gets the column type suitable to store values of the Java java.lang.Long type. |
Set<String> |
getMaterializedViewNames()
Retrieves the names of all materialized views in the default schema. |
Set<String> |
getMaterializedViewNames(String schemaName)
Retrieves the names of all materialized views in the given schema. |
Set<String> |
getRuleNames(String schemaName)
Retrieves the names of all rules in the given schema. |
Set<String> |
getSchemaNames()
|
Set<String> |
getSequenceNames()
Retrieves the names of all sequences in the default schema. |
Set<String> |
getSequenceNames(String schemaName)
Retrieves the names of all sequences in the given schema. |
long |
getSequenceValue(String sequenceName)
Returns the value of the sequence with the given name from the default schema. |
long |
getSequenceValue(String schemaName,
String sequenceName)
Returns the value of the sequence with the given name from the given schema. |
SQLHandler |
getSQLHandler()
Gets the sql handler. |
StoredIdentifierCase |
getStoredIdentifierCase()
|
Set<String> |
getStoredProcedureNames()
Retrieves the names of all stored procedures in the default schema. |
Set<String> |
getStoredProcedureNames(String schemaName)
Retrieves the names of all stored procedures in the given schema. |
abstract String |
getSupportedDatabaseDialect()
|
Set<String> |
getSynonymNames()
Retrieves the names of all synonyms in the default schema. |
Set<String> |
getSynonymNames(String schemaName)
Retrieves the names of all synonyms in the given schema. |
Set<String> |
getTableNames()
Returns the names of all tables in the default schema. |
abstract Set<String> |
getTableNames(String schemaName)
Returns the names of all tables in the given schema. |
String |
getTextDataType(int length)
Gets the column type suitable to store text values. |
Set<String> |
getTriggerNames()
Retrieves the names of all triggers in the default schema. |
Set<String> |
getTriggerNames(String schemaName)
Retrieves the names of all triggers in the given schema. |
Set<String> |
getTypeNames()
Retrieves the names of all types in the default schema. |
Set<String> |
getTypeNames(String schemaName)
Retrieves the names of all types in the given schema. |
Set<String> |
getViewNames()
Retrieves the names of all the views in the default schema. |
abstract Set<String> |
getViewNames(String schemaName)
Retrieves the names of all the views in the database schema. |
void |
incrementIdentityColumnToValue(String tableName,
String identityColumnName,
long identityValue)
Increments the identity value for the specified identity column on the specified table to the given value in the default schema. |
void |
incrementIdentityColumnToValue(String schemaName,
String tableName,
String identityColumnName,
long identityValue)
Increments the identity value for the specified identity column on the specified table to the given value in the given schema. |
void |
incrementSequenceToValue(String sequenceName,
long newSequenceValue)
Sets the next value of the sequence with the given name to the given sequence value in the default schema. |
void |
incrementSequenceToValue(String schemaName,
String sequenceName,
long newSequenceValue)
Sets the next value of the sequence with the given sequence name to the given sequence value in the given schema. |
boolean |
isQuoted(String identifier)
|
String |
qualified(String databaseObjectName)
Qualifies the given database object name with the name of the default schema. |
String |
qualified(String schemaName,
String databaseObjectName)
Qualifies the given database object name with the name of the given schema. |
String |
quoted(String databaseObjectName)
Put quotes around the given databaseObjectName, if the underlying DBMS supports quoted database object names. |
String |
removeIdentifierQuotes(String identifier)
|
void |
setDatabaseDefaultSchema()
Sets the current schema of the database. |
void |
setSettingIdentityColumnValueEnabled(String tableName,
boolean enabled)
Enables or disables the setting of identity value in insert and update statements in the default schema. |
void |
setSettingIdentityColumnValueEnabled(String schemaName,
String tableName,
boolean enabled)
Enables or disables the setting of identity value in insert and update statements in the given schema. |
boolean |
supportsCascade()
Indicates whether the underlying DBMS supports the cascade option for dropping tables and views. |
boolean |
supportsIdentityColumns()
Indicates whether the underlying DBMS supports identity columns |
boolean |
supportsMaterializedViews()
Indicates whether the underlying DBMS supports materialized views |
boolean |
supportsRules()
Indicates whether the underlying DBMS supports database rules |
boolean |
supportsSequences()
Indicates whether the underlying DBMS supports sequences |
boolean |
supportsSetDatabaseDefaultSchema()
Indicates whether the underlying DBMS supports the setting of the current schema. |
boolean |
supportsStoredProcedures()
Indicates whether the underlying DBMS supports stored procedures |
boolean |
supportsSynonyms()
Indicates whether the underlying DBMS supports synonyms |
boolean |
supportsTriggers()
Indicates whether the underlying DBMS supports triggers |
boolean |
supportsTypes()
Indicates whether the underlying DBMS supports database types |
String |
toCorrectCaseIdentifier(String identifier)
Converts the given identifier to uppercase/lowercase depending on the DBMS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DatabaseConnection databaseConnection
protected Set<String> schemaNames
protected IdentifierProcessor identifierProcessor
Constructor Detail |
---|
protected Database(DatabaseConnection databaseConnection, IdentifierProcessor identifierProcessor)
Method Detail |
---|
public abstract String getSupportedDatabaseDialect()
public StoredIdentifierCase getStoredIdentifierCase()
public String getIdentifierQuoteString()
public DatabaseInfo getDatabaseInfo()
public String getDatabaseName()
public DataSource getDataSource()
public SQLHandler getSQLHandler()
public String getDefaultSchemaName()
public Set<String> getSchemaNames()
public Set<String> getTableNames()
public abstract Set<String> getTableNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getColumnNames(String tableName)
tableName
- The table, not null
public abstract Set<String> getColumnNames(String schemaName, String tableName)
schemaName
- The schema, not nulltableName
- The table, not null
public Set<String> getViewNames()
public abstract Set<String> getViewNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getMaterializedViewNames()
public Set<String> getMaterializedViewNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getSynonymNames()
public Set<String> getSynonymNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getSequenceNames()
public Set<String> getSequenceNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getTriggerNames()
public Set<String> getTriggerNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getStoredProcedureNames()
public Set<String> getStoredProcedureNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getTypeNames()
public Set<String> getTypeNames(String schemaName)
schemaName
- The schema, not null
public Set<String> getRuleNames(String schemaName)
schemaName
- The schema, not null
public void dropTable(String tableName)
tableName
- The table to drop (case-sensitive), not nullpublic void dropTable(String schemaName, String tableName)
schemaName
- The schema, not nulltableName
- The table to drop (case-sensitive), not nullpublic void dropView(String viewName)
viewName
- The view to drop (case-sensitive), not nullpublic void dropView(String schemaName, String viewName)
schemaName
- The schema, not nullviewName
- The view to drop (case-sensitive), not nullpublic void dropMaterializedView(String viewName)
viewName
- The view to drop (case-sensitive), not nullpublic void dropMaterializedView(String schemaName, String viewName)
schemaName
- The schema, not nullviewName
- The view to drop (case-sensitive), not nullpublic void dropSynonym(String synonymName)
synonymName
- The synonym to drop (case-sensitive), not nullpublic void dropSynonym(String schemaName, String synonymName)
schemaName
- The schema, not nullsynonymName
- The synonym to drop (case-sensitive), not nullpublic void dropSequence(String sequenceName)
sequenceName
- The sequence to drop (case-sensitive), not nullpublic void dropSequence(String schemaName, String sequenceName)
schemaName
- The schema, not nullsequenceName
- The sequence to drop (case-sensitive), not nullpublic void dropTrigger(String triggerName)
triggerName
- The trigger to drop (case-sensitive), not nullpublic void dropTrigger(String schemaName, String triggerName)
schemaName
- The schema, not nulltriggerName
- The trigger to drop (case-sensitive), not nullpublic void dropStoredProcedure(String storedProcedureName)
storedProcedureName
- The stored procedure to drop (case-sensitive), not nullpublic void dropStoredProcedure(String schemaName, String storedProcedureName)
schemaName
- The schema, not nullstoredProcedureName
- The stored procedure to drop (case-sensitive), not nullpublic void dropType(String typeName)
typeName
- The type to drop (case-sensitive), not nullpublic void dropType(String schemaName, String typeName)
schemaName
- The schema, not nulltypeName
- The type to drop (case-sensitive), not nullpublic void dropRule(String schemaName, String ruleName)
schemaName
- The schema, not nullruleName
- The rule to drop (case-sensitive), not nullpublic void disableReferentialConstraints()
public abstract void disableReferentialConstraints(String schemaName)
schemaName
- The schema, not nullpublic void disableValueConstraints()
public abstract void disableValueConstraints(String schemaName)
schemaName
- The schema, not nullpublic long getSequenceValue(String sequenceName)
sequenceName
- The sequence, not null
public long getSequenceValue(String schemaName, String sequenceName)
schemaName
- The schema, not nullsequenceName
- The sequence, not null
public void incrementSequenceToValue(String sequenceName, long newSequenceValue)
sequenceName
- The sequence, not nullnewSequenceValue
- The value to setpublic void incrementSequenceToValue(String schemaName, String sequenceName, long newSequenceValue)
schemaName
- The schema, not nullsequenceName
- The sequence, not nullnewSequenceValue
- The value to setpublic Set<String> getIdentityColumnNames(String tableName)
tableName
- The table, not null
public Set<String> getIdentityColumnNames(String schemaName, String tableName)
schemaName
- The schema, not nulltableName
- The table, not null
public void incrementIdentityColumnToValue(String tableName, String identityColumnName, long identityValue)
tableName
- The table with the identity column, not nullidentityColumnName
- The column, not nullidentityValue
- The new valuepublic void incrementIdentityColumnToValue(String schemaName, String tableName, String identityColumnName, long identityValue)
schemaName
- The schema, not nulltableName
- The table with the identity column, not nullidentityColumnName
- The column, not nullidentityValue
- The new valuepublic void setDatabaseDefaultSchema()
public String getLongDataType()
java.lang.Long
type.
public String getTextDataType(int length)
length
- The nr of characters.
public String qualified(String databaseObjectName)
databaseObjectName
- The database object name to be qualified
public String qualified(String schemaName, String databaseObjectName)
schemaName
- The schema, not nulldatabaseObjectName
- The database object name to be qualified
public String quoted(String databaseObjectName)
databaseObjectName
- The name, not null
public String toCorrectCaseIdentifier(String identifier)
identifier
- The identifier, not null
public boolean isQuoted(String identifier)
identifier
- The identifier, not null
public String removeIdentifierQuotes(String identifier)
identifier
- The identifier, not null
public void setSettingIdentityColumnValueEnabled(String tableName, boolean enabled)
tableName
- The table with the identity column, not nullenabled
- True to enable, false to disablepublic void setSettingIdentityColumnValueEnabled(String schemaName, String tableName, boolean enabled)
schemaName
- The schema name, not nulltableName
- The table with the identity column, not nullenabled
- True to enable, false to disablepublic boolean supportsSynonyms()
public boolean supportsSequences()
public boolean supportsTriggers()
public boolean supportsStoredProcedures()
public boolean supportsTypes()
public boolean supportsRules()
public boolean supportsIdentityColumns()
public boolean supportsMaterializedViews()
public boolean supportsCascade()
public boolean supportsSetDatabaseDefaultSchema()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |