Class BaseConnection<D extends Database<?>>
- java.lang.Object
-
- migratedb.core.internal.database.base.BaseConnection<D>
-
- All Implemented Interfaces:
AutoCloseable,Connection<D>
- Direct Known Subclasses:
BigQueryConnection,CockroachDBConnection,DB2Connection,DerbyConnection,FirebirdConnection,H2Connection,HSQLDBConnection,IgniteThinConnection,InformixConnection,MySQLConnection,OracleConnection,PostgreSQLConnection,RedshiftConnection,SAPHANAConnection,SnowflakeConnection,SpannerConnection,SQLiteConnection,SQLServerConnection,SybaseASEConnection
public abstract class BaseConnection<D extends Database<?>> extends Object implements Connection<D>
-
-
Field Summary
Fields Modifier and Type Field Description protected Ddatabaseprotected JdbcTemplatejdbcTemplateprotected StringoriginalSchemaNameOrSearchPath
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseConnection(D database, Connection connection)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidchangeCurrentSchemaTo(Schema<?,?> schema)voidclose()protected voiddoChangeCurrentSchemaOrSearchPathTo(String schemaNameOrSearchPath)protected Schema<?,?>doGetCurrentSchema()protected voiddoRestoreOriginalState()Schema<?,?>getCurrentSchema()protected abstract StringgetCurrentSchemaNameOrSearchPath()ConnectiongetJdbcConnection()JdbcTemplategetJdbcTemplate()<T> Tlock(Table<?,?> table, Callable<T> callable)Locks this table and executes this callable.voidrestoreOriginalState()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface migratedb.core.api.internal.database.base.Connection
getSchema
-
-
-
-
Field Detail
-
jdbcTemplate
protected JdbcTemplate jdbcTemplate
-
originalSchemaNameOrSearchPath
protected final String originalSchemaNameOrSearchPath
-
-
Constructor Detail
-
BaseConnection
protected BaseConnection(D database, Connection connection)
-
-
Method Detail
-
getCurrentSchemaNameOrSearchPath
protected abstract String getCurrentSchemaNameOrSearchPath() throws SQLException
- Throws:
SQLException- when the current schema name or search path could not be retrieved.
-
getCurrentSchema
public final Schema<?,?> getCurrentSchema()
- Specified by:
getCurrentSchemain interfaceConnection<D extends Database<?>>
-
doGetCurrentSchema
protected Schema<?,?> doGetCurrentSchema() throws SQLException
- Throws:
SQLException
-
changeCurrentSchemaTo
public void changeCurrentSchemaTo(Schema<?,?> schema)
- Specified by:
changeCurrentSchemaToin interfaceConnection<D extends Database<?>>
-
doChangeCurrentSchemaOrSearchPathTo
protected void doChangeCurrentSchemaOrSearchPathTo(String schemaNameOrSearchPath) throws SQLException
- Parameters:
schemaNameOrSearchPath- The new current schema for this connection.- Throws:
SQLException- when the current schema could not be set.
-
lock
public <T> T lock(Table<?,?> table, Callable<T> callable)
Description copied from interface:ConnectionLocks this table and executes this callable.- Specified by:
lockin interfaceConnection<D extends Database<?>>- Returns:
- The result of the callable.
-
getJdbcTemplate
public final JdbcTemplate getJdbcTemplate()
- Specified by:
getJdbcTemplatein interfaceConnection<D extends Database<?>>
-
close
public final void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection<D extends Database<?>>
-
restoreOriginalState
public final void restoreOriginalState()
- Specified by:
restoreOriginalStatein interfaceConnection<D extends Database<?>>
-
doRestoreOriginalState
protected void doRestoreOriginalState() throws SQLException- Throws:
SQLException
-
getJdbcConnection
public final Connection getJdbcConnection()
- Specified by:
getJdbcConnectionin interfaceConnection<D extends Database<?>>
-
-