scriptella.spi
Interface Connection

All Known Implementing Classes:
AbstractConnection, JdbcConnection

public interface Connection

Represents a connection to the system provided by ScriptellaDriver.

The implementations are not required to be thread safe.

For most cases AbstractConnection may be used as a base for driver connection implementation.

Version:
1.0
Author:
Fyodor Kupolov

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.
 DialectIdentifier getDialectIdentifier()
          This method returns a language dialect identifier for this connection.
 long getExecutedStatementsCount()
          This method returns the number of executed statements or 0 if this feature is unsupported.
 void rollback()
          Rolls back a current transaction (if any).
 java.lang.String toString()
           
 

Method Detail

getDialectIdentifier

DialectIdentifier getDialectIdentifier()
                                       throws ProviderException
This method returns a language dialect identifier for this connection.

Returns:
dialect identifier.
Throws:
ProviderException - if driver failed to determine a language dialect.

executeScript

void executeScript(Resource scriptContent,
                   ParametersCallback parametersCallback)
                   throws ProviderException
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.
Throws:
ProviderException - if script execution failed.

executeQuery

void executeQuery(Resource queryContent,
                  ParametersCallback parametersCallback,
                  QueryCallback queryCallback)
                  throws ProviderException
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.
Throws:
ProviderException - if query execution failed.
See Also:
executeScript(scriptella.spi.Resource,scriptella.spi.ParametersCallback)

getExecutedStatementsCount

long getExecutedStatementsCount()
This method returns the number of executed statements or 0 if this feature is unsupported.

If possible the connection should collect statistics about the number of executed statement. It's recommended to provide the most actual execution statistics, i.e. increment internal statements counter during a script or a query execution, so the monitoring tools would be able to track progress.

Returns:
number of executed statements or 0 if this feature is unsupported.

commit

void commit()
            throws ProviderException
Commits a current transaction (if any).

Throwing an error during commit phase cause rollback.

Throws:
ProviderException - if a problem occured during commit phase.

rollback

void rollback()
              throws ProviderException,
                     java.lang.UnsupportedOperationException
Rolls back a current transaction (if any).

Throws:
ProviderException - if driver fails to roll back a transaction.
java.lang.UnsupportedOperationException - if transactions are not supported

close

void close()
           throws ProviderException
Closes the connection and releases all related resources.

Throws:
ProviderException - if a critical failure occured.

toString

java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
meaningful label for connection


Copyright © Copyright 2006-2009 The Scriptella Project Team.