com.atlassian.bamboo.utils.db
Class AbstractDbmsBean

java.lang.Object
  extended by com.atlassian.bamboo.utils.db.AbstractDbmsBean
All Implemented Interfaces:
DbmsBean
Direct Known Subclasses:
HsqlDbmsBean, MsSqlDbmsBean, MySqlDbmsBean, OracleDbmsBean, PostgreSqlDbmsBean

public abstract class AbstractDbmsBean
extends java.lang.Object
implements DbmsBean


Constructor Summary
AbstractDbmsBean()
           
 
Method Summary
 boolean dropColumn(java.sql.Connection connection, java.lang.String tableName, java.lang.String columnName)
          Checks whether given table contains the specified column and drops it
 boolean dropColumn(java.sql.Connection connection, java.lang.String tableName, java.lang.String columnName, java.util.List<java.lang.String> defaultConstraintNames, java.lang.String indexName)
          Checks whether given table contains the specified column and drops it, as well as foreign key constraints and index on the column.
protected  void dropConstraints(java.sql.Statement statement, java.lang.String tableName, java.lang.String columnName, java.util.List<java.lang.String> defaultConstraintNames)
           
protected  void dropIndex(java.sql.Statement statement, java.lang.String indexName)
           
 boolean isColumnPresent(java.sql.Connection connection, java.lang.String tableName, java.lang.String columnName)
          Checks whether given table contains the specified column.
 boolean isColumnPresent(java.sql.Statement statement, java.lang.String tableName, java.lang.String columnName)
          Checks whether given table contains the specified column.
 boolean isHsqldb()
           
 boolean isMsSqlServer()
           
 boolean isMySql()
           
 boolean isOracle()
           
 boolean isPostgreSql()
           
 boolean isTablePresent(java.sql.Connection connection, java.lang.String tableName)
          Checks whether given table is present in the database
 boolean isTablePresent(java.sql.Statement statement, java.lang.String tableName)
          Checks whether given table is present in the database
 
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
getQuery, prepareStatement
 

Constructor Detail

AbstractDbmsBean

public AbstractDbmsBean()
Method Detail

isColumnPresent

public boolean isColumnPresent(@NotNull
                               java.sql.Connection connection,
                               @NotNull
                               java.lang.String tableName,
                               @NotNull
                               java.lang.String columnName)
                        throws java.sql.SQLException
Description copied from interface: DbmsBean
Checks whether given table contains the specified column.

Specified by:
isColumnPresent in interface DbmsBean
Returns:
Throws:
java.sql.SQLException

isColumnPresent

public boolean isColumnPresent(@NotNull
                               java.sql.Statement statement,
                               @NotNull
                               java.lang.String tableName,
                               @NotNull
                               java.lang.String columnName)
                        throws java.sql.SQLException
Description copied from interface: DbmsBean
Checks whether given table contains the specified column.

Specified by:
isColumnPresent in interface DbmsBean
Returns:
Throws:
java.sql.SQLException

dropColumn

public boolean dropColumn(@NotNull
                          java.sql.Connection connection,
                          @NotNull
                          java.lang.String tableName,
                          @NotNull
                          java.lang.String columnName,
                          @NotNull
                          java.util.List<java.lang.String> defaultConstraintNames,
                          @Nullable
                          java.lang.String indexName)
                   throws java.sql.SQLException
Description copied from interface: DbmsBean
Checks whether given table contains the specified column and drops it, as well as foreign key constraints and index on the column. The method will automatically detect constraint names on DBMS that supports it or use provided names on DBMS that don't.

Specified by:
dropColumn in interface DbmsBean
Returns:
Throws:
java.sql.SQLException

dropConstraints

protected void dropConstraints(java.sql.Statement statement,
                               java.lang.String tableName,
                               java.lang.String columnName,
                               java.util.List<java.lang.String> defaultConstraintNames)

dropIndex

protected void dropIndex(java.sql.Statement statement,
                         java.lang.String indexName)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

dropColumn

public boolean dropColumn(@NotNull
                          java.sql.Connection connection,
                          @NotNull
                          java.lang.String tableName,
                          @NotNull
                          java.lang.String columnName)
                   throws java.sql.SQLException
Description copied from interface: DbmsBean
Checks whether given table contains the specified column and drops it

Specified by:
dropColumn in interface DbmsBean
Returns:
Throws:
java.sql.SQLException

isTablePresent

public boolean isTablePresent(@NotNull
                              java.sql.Connection connection,
                              @NotNull
                              java.lang.String tableName)
                       throws java.sql.SQLException
Description copied from interface: DbmsBean
Checks whether given table is present in the database

Specified by:
isTablePresent in interface DbmsBean
Parameters:
connection - connection used to verify DB table existence
tableName - name of DB table
Returns:
true if database is accessible and table exists, false otherwise
Throws:
java.sql.SQLException - if a database error occurs or connection is closed

isTablePresent

public boolean isTablePresent(@NotNull
                              java.sql.Statement statement,
                              @NotNull
                              java.lang.String tableName)
Description copied from interface: DbmsBean
Checks whether given table is present in the database

Specified by:
isTablePresent in interface DbmsBean
Parameters:
statement - statement used to verify DB table existence
tableName - name of DB table
Returns:
true if database is accessible and table exists, false otherwise

isHsqldb

public boolean isHsqldb()
Specified by:
isHsqldb in interface DbmsBean
Returns:
true if db configured in Hibernate is HSQL

isMsSqlServer

public boolean isMsSqlServer()
Specified by:
isMsSqlServer in interface DbmsBean
Returns:
true if db configured in Hibernate is Microsoft SQL Server

isMySql

public boolean isMySql()
Specified by:
isMySql in interface DbmsBean
Returns:
true if db configured in Hibernate is MySQL

isOracle

public boolean isOracle()
Specified by:
isOracle in interface DbmsBean
Returns:
true if db configured in Hibernate is Oracle

isPostgreSql

public boolean isPostgreSql()
Specified by:
isPostgreSql in interface DbmsBean
Returns:
true if db configured in Hibernate is PostgreSQL


Copyright © 2012 Atlassian. All Rights Reserved.