Package com.atlassian.bamboo.utils.db
Class PostgreSqlDbmsBean
java.lang.Object
com.atlassian.bamboo.utils.db.AbstractDbmsBean
com.atlassian.bamboo.utils.db.PostgreSqlDbmsBean
- 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 TypeMethodDescriptionprotected void
changeColumnDefinition
(Connection c, String table, String column, String sqlType, boolean isNullable) void
dropIndex
(Connection c, String table, String index) void
dropPrimaryKey
(Connection c, String tableName) Drops the primary key on a table.getColumns
(Connection c, @NotNull String table, @Nullable String column) @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 typegetIndexNames
(@NotNull Connection c, @NotNull String table, @Nullable String column) Returns indices set up on a given table, optionally narrowed down to a column.getIndices
(@NotNull Connection c, @NotNull String table) @NotNull String
getQuery
(@NotNull SqlQueryProvider sqlQueryProvider) Provide a different SQL query depending on SQL engine used.boolean
protected boolean
boolean
isTablePresent
(@NotNull Connection c, @NotNull String tableName) Checks whether given table is present in the databaseprotected String
quoteIfNeeded
(String name) Some tables in db can be stored in a case sensitive manner.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, changeColumnToNotNull, changeColumnType, changeTableNameToUpperCase, clobEquals, createColumn, createIndex, createPrimaryKey, createUniqueConstraint, dropColumn, dropConstraint, dropConstraints, dropForeignKeyConstraint, dropIndexIfExists, dropTable, getColumnDefinition, getColumnDefinitionString, getConstraintDefinitions, getConstraintType, getLargeTextTypeName, getSchema, getSchemaUncached, getSqlTypeName, getTables, isColumnPresent, isColumnPresent, isColumnPresent, isH2, isHsqldb, isMsSqlServer, isMySql, isOracle, migrateColumnType, newColumnDefinition, quote, 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
-
Constructor Details
-
PostgreSqlDbmsBean
public PostgreSqlDbmsBean()
-
-
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.
-
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
-
resizeVarcharColumn
public void resizeVarcharColumn(@NotNull @NotNull Connection connection, String tableName, String columnName, int newSize, boolean isNullable, @Nullable @Nullable String defaultValue) throws SQLException - Throws:
SQLException
-
isPostgreSql
public boolean isPostgreSql()- Specified by:
isPostgreSql
in interfaceDbmsBean
- Overrides:
isPostgreSql
in classAbstractDbmsBean
- Returns:
- true if db configured in Hibernate is PostgreSQL
-
getDatabaseType
Description copied from interface:BambooDatabaseTypeProvider
Detect used database type- Returns:
- database type
-
dropPrimaryKey
Description copied from interface:DbmsBean
Drops the primary key on a table.- Throws:
SQLException
-
changeColumnDefinition
protected void changeColumnDefinition(Connection c, String table, String column, String sqlType, boolean isNullable) throws SQLException - Overrides:
changeColumnDefinition
in classAbstractDbmsBean
- Throws:
SQLException
-
dropIndex
- Specified by:
dropIndex
in interfaceDbmsBean
- Overrides:
dropIndex
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
-
quoteIfNeeded
Description copied from class:AbstractDbmsBean
Some tables in db can be stored in a case sensitive manner. Then ala == ALA != "Ala" != "alA". This method ensures that the names leaving this bean can be used in a non-ambigous manner.- Overrides:
quoteIfNeeded
in classAbstractDbmsBean
-
getIndexNames
public Set<String> getIndexNames(@NotNull @NotNull Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException Description copied from interface:DbmsBean
Returns indices set up on a given table, optionally narrowed down to a column. For H2, it will also return implicit indices set up to support FK relationships. For SQL Server, it will return implicit PK indices. Case of returned index names is database specific - all comparisons should be case-independent.- Specified by:
getIndexNames
in interfaceDbmsBean
- Overrides:
getIndexNames
in classAbstractDbmsBean
- Throws:
SQLException
-
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
-
isTablePresent
public boolean isTablePresent(@NotNull @NotNull Connection c, @NotNull @NotNull String tableName) throws SQLException Description copied from interface:DbmsBean
Checks whether given table is present in the database- Specified by:
isTablePresent
in interfaceDbmsBean
- Overrides:
isTablePresent
in classAbstractDbmsBean
- Parameters:
c
- connection used to verify DB table existencetableName
- name of DB table- Returns:
- true if database is accessible and table exists, false otherwise
- Throws:
SQLException
- if a database error occurs or connection is closed
-
isTable
- Overrides:
isTable
in classAbstractDbmsBean
-
getColumns
public List<DbmsBean.ColumnDefinition> getColumns(Connection c, @NotNull @NotNull String table, @Nullable @Nullable String column) throws SQLException - Specified by:
getColumns
in interfaceDbmsBean
- Overrides:
getColumns
in classAbstractDbmsBean
- Throws:
SQLException
-