Package scriptella.spi
Class AbstractConnection
java.lang.Object
scriptella.spi.AbstractConnection
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
AbstractTextConnection,JaninoConnection,JdbcConnection,JexlConnection,LdapConnection,MailConnection,ScriptConnection,ScriptellaConnection,XPathConnection
A base class for connections.
Subclassing is more safe than directly implementing Connection interface.
- Version:
- 1.0
- Author:
- Fyodor Kupolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper class to use for executed statements counting. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMay be used by sublasses to allow full customizationprotectedAbstractConnection(ConnectionParameters parameters) Instantiates a connection with parameters.protectedAbstractConnection(DialectIdentifier dialectIdentifier, ConnectionParameters parameters) Instantiates a connection with dialectIdentifier and connection parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commits a current transaction (if any).This method returns a language dialect identifier for this connection.longThis method returns the number of executed statements or 0 if this feature is unsupported.booleanReturns readonly mode.voidrollback()Rolls back a current transaction (if any).protected voidsetDialectIdentifier(DialectIdentifier dialectIdentifier) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface scriptella.spi.Connection
close, executeQuery, executeScript
-
Field Details
-
counter
-
-
Constructor Details
-
AbstractConnection
protected AbstractConnection()May be used by sublasses to allow full customization -
AbstractConnection
Instantiates a connection with dialectIdentifier and connection parameters.- Parameters:
dialectIdentifier- dialect identifier.parameters- connection parameters to use for general properties.
-
AbstractConnection
Instantiates a connection with parameters.- Parameters:
parameters- connection parameters to use for general properties.
-
-
Method Details
-
getDialectIdentifier
Description copied from interface:ConnectionThis method returns a language dialect identifier for this connection.- Specified by:
getDialectIdentifierin interfaceConnection- Returns:
- dialect identifier.
-
setDialectIdentifier
-
getExecutedStatementsCount
public long getExecutedStatementsCount()Description copied from interface:ConnectionThis 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:
getExecutedStatementsCountin interfaceConnection- 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
Description copied from interface:ConnectionCommits a current transaction (if any).Throwing an error during commit phase cause
rollback.- Specified by:
commitin interfaceConnection- Throws:
ProviderException- if a problem occured during commit phase.
-
rollback
Description copied from interface:ConnectionRolls back a current transaction (if any).- Specified by:
rollbackin interfaceConnection- Throws:
ProviderException- if driver fails to roll back a transaction.UnsupportedOperationException- if transactions are not supported
-
toString
- Specified by:
toStringin interfaceConnection- Overrides:
toStringin classObject- Returns:
- meaningful label for connection
-