Package liquibase.database.jvm
Class JdbcConnection
- java.lang.Object
-
- liquibase.database.jvm.JdbcConnection
-
- All Implemented Interfaces:
AutoCloseable
,DatabaseConnection
,PrioritizedService
- Direct Known Subclasses:
DerbyConnection
,HsqlConnection
,SybaseASAConnection
,SybaseConnection
public class JdbcConnection extends Object implements DatabaseConnection
A ConnectionWrapper implementation which delegates completely to an underlying java.sql.connection.
-
-
Field Summary
-
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description JdbcConnection()
JdbcConnection(Connection connection)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface liquibase.database.DatabaseConnection
supports
-
-
-
-
Constructor Detail
-
JdbcConnection
public JdbcConnection()
-
JdbcConnection
public JdbcConnection(Connection connection)
-
-
Method Detail
-
getPriority
public int getPriority()
- Specified by:
getPriority
in interfacePrioritizedService
-
open
public void open(String url, Driver driverObject, Properties driverProperties) throws DatabaseException
- Specified by:
open
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
attached
public void attached(Database database)
- Specified by:
attached
in interfaceDatabaseConnection
-
getDatabaseProductName
public String getDatabaseProductName() throws DatabaseException
- Specified by:
getDatabaseProductName
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getDatabaseProductVersion
public String getDatabaseProductVersion() throws DatabaseException
- Specified by:
getDatabaseProductVersion
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getDatabaseMajorVersion
public int getDatabaseMajorVersion() throws DatabaseException
- Specified by:
getDatabaseMajorVersion
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getDatabaseMinorVersion
public int getDatabaseMinorVersion() throws DatabaseException
- Specified by:
getDatabaseMinorVersion
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getURL
public String getURL()
- Specified by:
getURL
in interfaceDatabaseConnection
-
sanitizeUrl
public static String sanitizeUrl(String url)
Remove any secure information from the URL. Used for logging purposes Strips off the;password=
property from string. Note: it does not remove the password from theuser:password@host
section- Parameters:
url
- string to remove password=xxx from- Returns:
- modified string
-
getConnectionUrl
protected String getConnectionUrl() throws SQLException
- Throws:
SQLException
-
getConnectionUserName
public String getConnectionUserName()
- Specified by:
getConnectionUserName
in interfaceDatabaseConnection
-
getWrappedConnection
public Connection getWrappedConnection()
Returns the connection that this Delegate is using.- Returns:
- The connection originally passed in the constructor
-
clearWarnings
public void clearWarnings() throws DatabaseException
- Throws:
DatabaseException
-
close
public void close() throws DatabaseException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
commit
public void commit() throws DatabaseException
- Specified by:
commit
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
createStatement
public Statement createStatement() throws DatabaseException
- Throws:
DatabaseException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws DatabaseException
- Throws:
DatabaseException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws DatabaseException
- Throws:
DatabaseException
-
getAutoCommit
public boolean getAutoCommit() throws DatabaseException
- Specified by:
getAutoCommit
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getCatalog
public String getCatalog() throws DatabaseException
- Specified by:
getCatalog
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
getHoldability
public int getHoldability() throws DatabaseException
- Throws:
DatabaseException
-
getMetaData
public DatabaseMetaData getMetaData() throws DatabaseException
- Throws:
DatabaseException
-
getTransactionIsolation
public int getTransactionIsolation() throws DatabaseException
- Throws:
DatabaseException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws DatabaseException
- Throws:
DatabaseException
-
getWarnings
public SQLWarning getWarnings() throws DatabaseException
- Throws:
DatabaseException
-
isClosed
public boolean isClosed() throws DatabaseException
- Specified by:
isClosed
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
isReadOnly
public boolean isReadOnly() throws DatabaseException
- Throws:
DatabaseException
-
nativeSQL
public String nativeSQL(String sql) throws DatabaseException
- Specified by:
nativeSQL
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws DatabaseException
- Throws:
DatabaseException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws DatabaseException
- Throws:
DatabaseException
-
prepareCall
public CallableStatement prepareCall(String sql) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws DatabaseException
- Throws:
DatabaseException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws DatabaseException
- Throws:
DatabaseException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws DatabaseException
- Throws:
DatabaseException
-
rollback
public void rollback() throws DatabaseException
- Specified by:
rollback
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
rollback
public void rollback(Savepoint savepoint) throws DatabaseException
- Throws:
DatabaseException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws DatabaseException
- Specified by:
setAutoCommit
in interfaceDatabaseConnection
- Throws:
DatabaseException
-
setCatalog
public void setCatalog(String catalog) throws DatabaseException
- Throws:
DatabaseException
-
setHoldability
public void setHoldability(int holdability) throws DatabaseException
- Throws:
DatabaseException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws DatabaseException
- Throws:
DatabaseException
-
setSavepoint
public Savepoint setSavepoint() throws DatabaseException
- Throws:
DatabaseException
-
setSavepoint
public Savepoint setSavepoint(String name) throws DatabaseException
- Throws:
DatabaseException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws DatabaseException
- Throws:
DatabaseException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws DatabaseException
- Throws:
DatabaseException
-
getUnderlyingConnection
public Connection getUnderlyingConnection()
-
supportsBatchUpdates
public boolean supportsBatchUpdates() throws DatabaseException
- Throws:
DatabaseException
-
-