scriptella.spi
Class AbstractConnection

java.lang.Object
  extended by scriptella.spi.AbstractConnection
All Implemented Interfaces:
Connection
Direct Known Subclasses:
JdbcConnection

public abstract class AbstractConnection
extends java.lang.Object
implements Connection

A base class for connections.

Subclassing is more safe than directly implementing Connection interface.

Version:
1.0
Author:
Fyodor Kupolov

Nested Class Summary
static class AbstractConnection.StatementCounter
          Helper class to use for executed statements counting.
 
Field Summary
protected  AbstractConnection.StatementCounter counter
           
 
Constructor Summary
protected AbstractConnection()
          May be used by sublasses to allow full customization
protected AbstractConnection(ConnectionParameters parameters)
          Instantiates a connection with parameters.
protected AbstractConnection(DialectIdentifier dialectIdentifier, ConnectionParameters parameters)
          Instantiates a connection with dialectIdentifier and connection parameters.
 
Method Summary
 void commit()
          Commits a current transaction (if any).
 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.
 boolean isReadonly()
          Returns readonly mode.
 void rollback()
          Rolls back a current transaction (if any).
protected  void setDialectIdentifier(DialectIdentifier dialectIdentifier)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface scriptella.spi.Connection
close, executeQuery, executeScript
 

Field Detail

counter

protected final AbstractConnection.StatementCounter counter
Constructor Detail

AbstractConnection

protected AbstractConnection()
May be used by sublasses to allow full customization


AbstractConnection

protected AbstractConnection(DialectIdentifier dialectIdentifier,
                             ConnectionParameters parameters)
Instantiates a connection with dialectIdentifier and connection parameters.

Parameters:
dialectIdentifier - dialect identifier.
parameters - connection parameters to use for general properties.

AbstractConnection

protected AbstractConnection(ConnectionParameters parameters)
Instantiates a connection with parameters.

Parameters:
parameters - connection parameters to use for general properties.
Method Detail

getDialectIdentifier

public DialectIdentifier getDialectIdentifier()
Description copied from interface: Connection
This method returns a language dialect identifier for this connection.

Specified by:
getDialectIdentifier in interface Connection
Returns:
dialect identifier.

setDialectIdentifier

protected void setDialectIdentifier(DialectIdentifier dialectIdentifier)

getExecutedStatementsCount

public long getExecutedStatementsCount()
Description copied from interface: Connection
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.

Specified by:
getExecutedStatementsCount in interface Connection
Returns:
number of executed statements or 0 if this feature is unsupported.

isReadonly

public boolean isReadonly()
Returns readonly mode.

readonly=true means updates must be skipped by the driver. This property is configurable by readonly property of connection declaration element. Drivers are not required to support this feauture.

Returns:
true if connection is in readonly mode.

commit

public void commit()
            throws ProviderException
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
Throws:
ProviderException - if a problem occured during commit phase.

rollback

public void rollback()
              throws ProviderException,
                     java.lang.UnsupportedOperationException
Description copied from interface: Connection
Rolls back a current transaction (if any).

Specified by:
rollback in interface Connection
Throws:
ProviderException - if driver fails to roll back a transaction.
java.lang.UnsupportedOperationException - if transactions are not supported

toString

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


Copyright © Copyright 2006-2009 The Scriptella Project Team.