Class AbstractConnection

java.lang.Object
scriptella.spi.AbstractConnection
All Implemented Interfaces:
Connection
Direct Known Subclasses:
AbstractTextConnection, JaninoConnection, JdbcConnection, JexlConnection, LdapConnection, MailConnection, ScriptConnection, ScriptellaConnection, XPathConnection

public abstract class AbstractConnection extends Object implements Connection
A base class for connections.

Subclassing is more safe than directly implementing Connection interface.

Version:
1.0
Author:
Fyodor Kupolov
  • Field Details

  • Constructor Details

    • 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 Details

    • 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, 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.
      UnsupportedOperationException - if transactions are not supported
    • toString

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