Package com.atlassian.bamboo.utils.db
Class H2DbmsBean
- java.lang.Object
-
- com.atlassian.bamboo.utils.db.AbstractDbmsBean
-
- com.atlassian.bamboo.utils.db.H2DbmsBean
-
- All Implemented Interfaces:
BambooDatabaseTypeProvider
,DbmsBean
public class H2DbmsBean extends AbstractDbmsBean
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.utils.db.DbmsBean
DbmsBean.ColumnDefinition, DbmsBean.ConstraintDefinition, DbmsBean.IndexDefinition
-
-
Field Summary
-
Fields inherited from class com.atlassian.bamboo.utils.db.AbstractDbmsBean
LARGE_STRING_TYPE
-
-
Constructor Summary
Constructors Constructor Description H2DbmsBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dropIndex(Connection c, String table, String index)
void
dropPrimaryKey(Connection connection, String tableName)
Drops the primary key on a table.@NotNull String
getConcat(String... values)
Provide a different SQL concatenation operator depending on SQL engine used.@NotNull Collection<DbmsBean.ConstraintDefinition>
getConstraints(Connection connection, String table, @Nullable String column)
Fetch information about constraintsprotected DbmsBean.ConstraintDefinition.ConstraintType
getConstraintType(String typeName)
DatabaseType
getDatabaseType()
Detect used database typeCollection<DbmsBean.IndexDefinition>
getIndices(@NotNull Connection c, @NotNull String table)
@NotNull String
getQuery(@NotNull SqlQueryProvider sqlQueryProvider)
Provide a different SQL query depending on SQL engine used.protected void
handleException(@NotNull Connection connection, @NotNull String table, @NotNull SQLException e, BambooRunnables.Throwing<SQLException> command)
Attempts to handle an SQL exception, performingcommand
after properly fixing the state of the database if the cause of the problem is known.boolean
isH2()
void
renameColumn(Connection c, String tableName, String oldName, String newName)
Rename columns.void
resizeVarcharColumn(@NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable String defaultValue)
-
Methods inherited from class com.atlassian.bamboo.utils.db.AbstractDbmsBean
actuallyChangeColumnToNotNull, addColumn, changeColumnDefinition, changeColumnToNotNull, changeColumnType, changeTableNameToUpperCase, clobEquals, createColumn, createIndex, createPrimaryKey, createUniqueConstraint, dropColumn, dropConstraint, dropConstraints, dropForeignKeyConstraint, dropIndexIfExists, dropTable, getColumnDefinition, getColumnDefinitionString, getColumns, getConstraintDefinitions, getIndexNames, getLargeTextTypeName, getSchema, getSchemaUncached, getSqlTypeName, getTables, isColumnPresent, isColumnPresent, isColumnPresent, isHsqldb, isMsSqlServer, isMySql, isOracle, isPostgreSql, isTable, isTablePresent, migrateColumnType, newColumnDefinition, quote, quoteIfNeeded, toLowerCase
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.utils.db.DbmsBean
getCatalog
-
-
-
-
Method Detail
-
getQuery
@NotNull public @NotNull String getQuery(@NotNull @NotNull SqlQueryProvider sqlQueryProvider)
Description copied from interface:DbmsBean
Provide a different SQL query depending on SQL engine used.- Returns:
-
getConcat
@NotNull public @NotNull String getConcat(String... values)
Description copied from interface:DbmsBean
Provide a different SQL concatenation operator depending on SQL engine used.- Parameters:
values
- the values to concatenate.- Returns:
- the concatenation SQL to append to a query.
-
getConstraints
@NotNull public @NotNull Collection<DbmsBean.ConstraintDefinition> getConstraints(Connection connection, String table, @Nullable @Nullable String column) throws SQLException
Description copied from interface:DbmsBean
Fetch information about constraints- Throws:
SQLException
-
getConstraintType
protected DbmsBean.ConstraintDefinition.ConstraintType getConstraintType(String typeName)
- Overrides:
getConstraintType
in classAbstractDbmsBean
-
resizeVarcharColumn
public void resizeVarcharColumn(@NotNull @NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable @Nullable String defaultValue) throws SQLException
- Throws:
SQLException
-
getDatabaseType
public DatabaseType getDatabaseType()
Description copied from interface:BambooDatabaseTypeProvider
Detect used database type- Returns:
- database type
-
isH2
public boolean isH2()
- Specified by:
isH2
in interfaceDbmsBean
- Overrides:
isH2
in classAbstractDbmsBean
- Returns:
- true if db configured in Hibernate is H2
-
dropPrimaryKey
public void dropPrimaryKey(Connection connection, String tableName) throws SQLException
Description copied from interface:DbmsBean
Drops the primary key on a table.- Throws:
SQLException
-
renameColumn
public void renameColumn(Connection c, String tableName, String oldName, String newName) throws SQLException
Description copied from interface:DbmsBean
Rename columns.- Specified by:
renameColumn
in interfaceDbmsBean
- Specified by:
renameColumn
in classAbstractDbmsBean
- Throws:
SQLException
-
dropIndex
public void dropIndex(Connection c, String table, String index) throws SQLException
- Specified by:
dropIndex
in interfaceDbmsBean
- Overrides:
dropIndex
in classAbstractDbmsBean
- Throws:
SQLException
-
handleException
protected void handleException(@NotNull @NotNull Connection connection, @NotNull @NotNull String table, @NotNull @NotNull SQLException e, @NotNull BambooRunnables.Throwing<SQLException> command) throws SQLException
Attempts to handle an SQL exception, performingcommand
after properly fixing the state of the database if the cause of the problem is known. Re-throws the exception if the cause is unknown.- Parameters:
connection
- database connectiontable
- table to which the problem is relatede
- exception throwncommand
- command to execute after properly addressing the issue- Throws:
SQLException
- if thrown bycommand
, or if exception could not be handled ande
is rethrown
-
getIndices
public Collection<DbmsBean.IndexDefinition> getIndices(@NotNull @NotNull Connection c, @NotNull @NotNull String table) throws SQLException
- Specified by:
getIndices
in interfaceDbmsBean
- Overrides:
getIndices
in classAbstractDbmsBean
- Throws:
SQLException
-
-