scriptella.jdbc
Class JdbcConnection

java.lang.Object
  extended by scriptella.spi.AbstractConnection
      extended by scriptella.jdbc.JdbcConnection
All Implemented Interfaces:
Connection

public class JdbcConnection
extends AbstractConnection

Represents a JDBC connection.

Version:
1.0
Author:
Fyodor Kupolov

Nested Class Summary
 
Nested classes/interfaces inherited from class scriptella.spi.AbstractConnection
AbstractConnection.StatementCounter
 
Field Summary
static java.lang.String AUTOCOMMIT_KEY
           
static java.lang.String AUTOCOMMIT_SIZE_KEY
           
protected  int autocommitSize
           
protected  boolean keepformat
           
static java.lang.String KEEPFORMAT_KEY
           
protected  java.lang.String separator
           
protected  boolean separatorSingleLine
           
static java.lang.String STATEMENT_CACHE_KEY
           
static java.lang.String STATEMENT_SEPARATOR_KEY
           
static java.lang.String STATEMENT_SEPARATOR_SINGLELINE_KEY
           
static java.lang.String TRANSACTION_ISOLATION_KEY
           
static java.lang.String TRANSACTION_ISOLATION_READ_COMMITTED
           
static java.lang.String TRANSACTION_ISOLATION_READ_UNCOMMITTED
           
static java.lang.String TRANSACTION_ISOLATION_REPEATABLE_READ
           
static java.lang.String TRANSACTION_ISOLATION_SERIALIZABLE
           
 
Fields inherited from class scriptella.spi.AbstractConnection
counter
 
Constructor Summary
JdbcConnection(java.sql.Connection con, ConnectionParameters parameters)
           
 
Method Summary
 void close()
          Closes the connection and releases all related resources.
 void commit()
          Commits a current transaction (if any).
 void executeQuery(Resource queryContent, ParametersCallback parametersCallback, QueryCallback queryCallback)
          Executes a query specified by its content.
 void executeScript(Resource scriptContent, ParametersCallback parametersCallback)
          Executes a script specified by its content.
 java.sql.Connection getNativeConnection()
           
protected  void init(ConnectionParameters parameters)
          Called in constructor
protected  void initDialectIdentifier()
          Initializes dialect identifier for connection.
 void rollback()
          Rolls back a current transaction (if any).
 java.lang.String toString()
           
 
Methods inherited from class scriptella.spi.AbstractConnection
getDialectIdentifier, getExecutedStatementsCount, isReadonly, setDialectIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATEMENT_CACHE_KEY

public static final java.lang.String STATEMENT_CACHE_KEY
See Also:
Constant Field Values

STATEMENT_SEPARATOR_KEY

public static final java.lang.String STATEMENT_SEPARATOR_KEY
See Also:
Constant Field Values

STATEMENT_SEPARATOR_SINGLELINE_KEY

public static final java.lang.String STATEMENT_SEPARATOR_SINGLELINE_KEY
See Also:
Constant Field Values

KEEPFORMAT_KEY

public static final java.lang.String KEEPFORMAT_KEY
See Also:
Constant Field Values

AUTOCOMMIT_KEY

public static final java.lang.String AUTOCOMMIT_KEY
See Also:
Constant Field Values

AUTOCOMMIT_SIZE_KEY

public static final java.lang.String AUTOCOMMIT_SIZE_KEY
See Also:
Constant Field Values

TRANSACTION_ISOLATION_KEY

public static final java.lang.String TRANSACTION_ISOLATION_KEY
See Also:
Constant Field Values

TRANSACTION_ISOLATION_READ_UNCOMMITTED

public static final java.lang.String TRANSACTION_ISOLATION_READ_UNCOMMITTED
See Also:
Constant Field Values

TRANSACTION_ISOLATION_READ_COMMITTED

public static final java.lang.String TRANSACTION_ISOLATION_READ_COMMITTED
See Also:
Constant Field Values

TRANSACTION_ISOLATION_REPEATABLE_READ

public static final java.lang.String TRANSACTION_ISOLATION_REPEATABLE_READ
See Also:
Constant Field Values

TRANSACTION_ISOLATION_SERIALIZABLE

public static final java.lang.String TRANSACTION_ISOLATION_SERIALIZABLE
See Also:
Constant Field Values

separator

protected java.lang.String separator

separatorSingleLine

protected boolean separatorSingleLine

keepformat

protected boolean keepformat

autocommitSize

protected int autocommitSize
Constructor Detail

JdbcConnection

public JdbcConnection(java.sql.Connection con,
                      ConnectionParameters parameters)
Method Detail

init

protected void init(ConnectionParameters parameters)
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_DIALECT is used.

May be overriden by subclasses.


executeScript

public void executeScript(Resource scriptContent,
                          ParametersCallback parametersCallback)
Description copied from interface: Connection
Executes 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 resources can be safely cached.

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: Connection
Executes a query specified by its content.

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:
Connection.executeScript(scriptella.spi.Resource,scriptella.spi.ParametersCallback)

commit

public void commit()
Description copied from interface: Connection
Commits a current transaction (if any).

Throwing an error during commit phase cause rollback.

Specified by:
commit in interface Connection
Overrides:
commit in class AbstractConnection

rollback

public void rollback()
Description copied from interface: Connection
Rolls back a current transaction (if any).

Specified by:
rollback in interface Connection
Overrides:
rollback in class AbstractConnection

close

public void close()
Description copied from interface: Connection
Closes the connection and releases all related resources.


getNativeConnection

public java.sql.Connection getNativeConnection()

toString

public java.lang.String toString()
Specified by:
toString in interface Connection
Overrides:
toString in class AbstractConnection
Returns:
meaningful label for connection


Copyright © Copyright 2006-2009 The Scriptella Project Team.