Package com.atlassian.bamboo.utils.db
Class MsSqlDbmsBean
java.lang.Object
com.atlassian.bamboo.utils.db.AbstractDbmsBean
com.atlassian.bamboo.utils.db.MsSqlDbmsBean
- All Implemented Interfaces:
BambooDatabaseTypeProvider
,DbmsBean
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
actuallyChangeColumnToNotNull
(Connection c, String tableName, String columnName) protected void
changeColumnDefinition
(Connection c, String table, String column, String sqlType, boolean isNullable) void
changeTableNameToUpperCase
(Connection connection, String oldName) Rename table from lower case to upper case.@NotNull String
clobEquals
(@NotNull String columnName) Comparison string for CLOB column.protected void
dropConstraints
(Connection connection, String tableName, String columnName) void
dropIndex
(Connection c, String table, String index) void
dropPrimaryKey
(Connection connection, String tableName) Drops the primary key on a table.@NotNull String
Provide a different SQL concatenation operator depending on SQL engine used.@NotNull Collection<DbmsBean.ConstraintDefinition>
getConstraints
(Connection connection, @NotNull String table, @Nullable String column) Fetch information about constraintsDetect used database type@NotNull String
getQuery
(@NotNull SqlQueryProvider sqlQueryProvider) Provide a different SQL query depending on SQL engine used.protected @NotNull String
getSqlTypeName
(int type) boolean
isColumnPresent
(@NotNull Statement statement, @NotNull String tableName, @NotNull String columnName) Checks whether given table contains the specified column.boolean
protected DbmsBean.ColumnDefinition
newColumnDefinition
(String columnName, int dataType, String dataTypeName, OptionalInt columnSize, Optional<Boolean> isNullable) 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
addColumn, changeColumnToNotNull, changeColumnType, createColumn, createIndex, createPrimaryKey, createUniqueConstraint, dropColumn, dropConstraint, dropForeignKeyConstraint, dropIndexIfExists, dropTable, getColumnDefinition, getColumnDefinitionString, getColumns, getConstraintDefinitions, getConstraintType, getIndexNames, getIndices, getLargeTextTypeName, getSchema, getSchemaUncached, getTables, hasIndexOnColumns, isColumnPresent, isColumnPresent, isH2, isMySql, isOracle, isPostgreSql, isTable, isTablePresent, migrateColumnType, quote, quoteIfNeeded, toLowerCase, unquoteIfNeeded
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
-
Constructor Details
-
MsSqlDbmsBean
public MsSqlDbmsBean()
-
-
Method Details
-
getQuery
Description copied from interface:DbmsBean
Provide a different SQL query depending on SQL engine used.- Returns:
-
getConcat
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.
-
resizeVarcharColumn
public void resizeVarcharColumn(@NotNull @NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable @Nullable String defaultValue) throws SQLException - Throws:
SQLException
-
isMsSqlServer
public boolean isMsSqlServer()- Specified by:
isMsSqlServer
in interfaceDbmsBean
- Overrides:
isMsSqlServer
in classAbstractDbmsBean
- Returns:
- true if db configured in Hibernate is Microsoft SQL Server
-
getDatabaseType
Description copied from interface:BambooDatabaseTypeProvider
Detect used database type- Returns:
- database type
-
dropIndex
- Specified by:
dropIndex
in interfaceDbmsBean
- Overrides:
dropIndex
in classAbstractDbmsBean
- Throws:
SQLException
-
dropConstraints
- Overrides:
dropConstraints
in classAbstractDbmsBean
-
isColumnPresent
public boolean isColumnPresent(@NotNull @NotNull Statement statement, @NotNull @NotNull String tableName, @NotNull @NotNull String columnName) throws SQLException Description copied from interface:DbmsBean
Checks whether given table contains the specified column.- Specified by:
isColumnPresent
in interfaceDbmsBean
- Overrides:
isColumnPresent
in classAbstractDbmsBean
- Returns:
- true if given table contains the specified column or false when either column or table doesn't exist
- Throws:
SQLException
-
dropPrimaryKey
Description copied from interface:DbmsBean
Drops the primary key on a table.- Throws:
SQLException
-
getConstraints
@NotNull public @NotNull Collection<DbmsBean.ConstraintDefinition> getConstraints(Connection connection, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException Description copied from interface:DbmsBean
Fetch information about constraints- Throws:
SQLException
-
changeTableNameToUpperCase
Description copied from interface:DbmsBean
Rename table from lower case to upper case. No-op if database is table names are case insensitive.- Specified by:
changeTableNameToUpperCase
in interfaceDbmsBean
- Overrides:
changeTableNameToUpperCase
in classAbstractDbmsBean
- 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
-
clobEquals
Description copied from interface:DbmsBean
Comparison string for CLOB column.- Specified by:
clobEquals
in interfaceDbmsBean
- Overrides:
clobEquals
in classAbstractDbmsBean
- Parameters:
columnName
- column name- Returns:
- string for prepared statement
-
newColumnDefinition
protected DbmsBean.ColumnDefinition newColumnDefinition(String columnName, int dataType, String dataTypeName, OptionalInt columnSize, Optional<Boolean> isNullable) - Overrides:
newColumnDefinition
in classAbstractDbmsBean
-
actuallyChangeColumnToNotNull
public void actuallyChangeColumnToNotNull(Connection c, String tableName, String columnName) throws SQLException - Overrides:
actuallyChangeColumnToNotNull
in classAbstractDbmsBean
- Throws:
SQLException
-
changeColumnDefinition
protected void changeColumnDefinition(Connection c, String table, String column, String sqlType, boolean isNullable) throws SQLException - Overrides:
changeColumnDefinition
in classAbstractDbmsBean
- Throws:
SQLException
-
getSqlTypeName
- Overrides:
getSqlTypeName
in classAbstractDbmsBean
-