Package scriptella.jdbc
Class JdbcConnection
java.lang.Object
scriptella.spi.AbstractConnection
scriptella.jdbc.JdbcConnection
- All Implemented Interfaces:
Connection,NativeConnectionProvider
- Direct Known Subclasses:
OracleConnection
Represents a JDBC connection.
TODO Extract JDBCConnectionParameters class and JDBCStatementFactory as described in statement cache
- Version:
- 1.0
- Author:
- Fyodor Kupolov
-
Nested Class Summary
Nested classes/interfaces inherited from class scriptella.spi.AbstractConnection
AbstractConnection.StatementCounter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected intstatic final Stringprotected booleanprotected booleanstatic final Stringprotected Stringprotected booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected intprotected intprotected intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class scriptella.spi.AbstractConnection
counter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection and releases all related resources.voidcommit()Commits a current transaction (if any).voidexecuteQuery(Resource queryContent, ParametersCallback parametersCallback, QueryCallback queryCallback) Executes a query specified by its content.voidexecuteScript(Resource scriptContent, ParametersCallback parametersCallback) Executes a script specified by its content.voidflush()Returns the native connection which is wrapped by this object or null if this information is not available.protected voidinit(ConnectionParameters parameters) Called in constructorprotected voidInitializes dialect identifier for connection.protected scriptella.jdbc.StatementCacheCreates an instance of statement cache.voidrollback()Rolls back a current transaction (if any).toString()Methods inherited from class scriptella.spi.AbstractConnection
getDialectIdentifier, getExecutedStatementsCount, isReadonly, setDialectIdentifier
-
Field Details
-
STATEMENT_CACHE_KEY
- See Also:
-
STATEMENT_SEPARATOR_KEY
- See Also:
-
STATEMENT_SEPARATOR_SINGLELINE_KEY
- See Also:
-
STATEMENT_BATCH_SIZE
- See Also:
-
STATEMENT_FETCH_SIZE
- See Also:
-
KEEPFORMAT_KEY
- See Also:
-
AUTOCOMMIT_KEY
- See Also:
-
AUTOCOMMIT_SIZE_KEY
- See Also:
-
FLUSH_BEFORE_QUERY
- See Also:
-
TRANSACTION_ISOLATION_KEY
- See Also:
-
TRANSACTION_ISOLATION_READ_UNCOMMITTED
- See Also:
-
TRANSACTION_ISOLATION_READ_COMMITTED
- See Also:
-
TRANSACTION_ISOLATION_REPEATABLE_READ
- See Also:
-
TRANSACTION_ISOLATION_SERIALIZABLE
- See Also:
-
statementCacheSize
protected int statementCacheSize -
statementBatchSize
protected int statementBatchSize -
statementFetchSize
protected int statementFetchSize -
flushBeforeQuery
protected boolean flushBeforeQuery -
separator
-
separatorSingleLine
protected boolean separatorSingleLine -
keepformat
protected boolean keepformat -
autocommitSize
protected int autocommitSize
-
-
Constructor Details
-
JdbcConnection
-
-
Method Details
-
init
Called in constructor- Parameters:
parameters- connection parameters.
-
initDialectIdentifier
protected void initDialectIdentifier()Initializes dialect identifier for connection. If driver doesn't support DatabaseMetaData or other problem occurs,DialectIdentifier.NULL_DIALECTis used.May be overriden by subclasses.
-
executeScript
Description copied from interface:ConnectionExecutes a script specified by its content.scriptContent may be used as a key for caching purposes, i.e. provider may precompile scripts and use compiled versions for subsequent executions. Please note that only inline
text resourcescan be safely cached.- Specified by:
executeScriptin interfaceConnection- Parameters:
scriptContent- script content. Cannot be null.parametersCallback- callback to get parameter values. Cannot be null.
-
executeQuery
public void executeQuery(Resource queryContent, ParametersCallback parametersCallback, QueryCallback queryCallback) Description copied from interface:ConnectionExecutes a query specified by its content.- Specified by:
executeQueryin interfaceConnection- Parameters:
queryContent- query content. Cannot be null.parametersCallback- callback to get parameter values. Cannot be null.queryCallback- callback to call for each result set element produced by this query. Cannot be null.- See Also:
-
newStatementCache
protected scriptella.jdbc.StatementCache newStatementCache()Creates an instance of statement cache.- Returns:
- new instance of statement cache.
-
commit
public void commit()Description copied from interface:ConnectionCommits a current transaction (if any).Throwing an error during commit phase cause
rollback.- Specified by:
commitin interfaceConnection- Overrides:
commitin classAbstractConnection
-
rollback
public void rollback()Description copied from interface:ConnectionRolls back a current transaction (if any).- Specified by:
rollbackin interfaceConnection- Overrides:
rollbackin classAbstractConnection
-
flush
- Throws:
ProviderException
-
close
public void close()Description copied from interface:ConnectionCloses the connection and releases all related resources.- Specified by:
closein interfaceConnection
-
getNativeConnection
Description copied from interface:NativeConnectionProviderReturns the native connection which is wrapped by this object or null if this information is not available.- Specified by:
getNativeConnectionin interfaceNativeConnectionProvider- Returns:
- native connection which is wrapped by this object.
-
toString
- Specified by:
toStringin interfaceConnection- Overrides:
toStringin classAbstractConnection- Returns:
- meaningful label for connection
-