Esri Geoportal Server
1.0

com.esri.gpt.framework.sql
Class ManagedConnection

java.lang.Object
  extended by com.esri.gpt.framework.sql.ManagedConnection

public final class ManagedConnection
extends Object

Acts as a wrapper for a JDBC connection.

This class is intended for use by a single execution thread.


Constructor Summary
protected ManagedConnection(DatabaseReference databaseReference)
          Construct based upon a supplied DatabaseReference.
 
Method Summary
protected  void close()
          Closes the underlying JDBC connection.
 void commit()
          Handles the commit for the transaction.
protected  void finalize()
          Finalize on garbage collection.
 IClobMutator getClobMutator()
          Gets clob mutator.
protected  DatabaseReference getDatabaseReference()
          Gets the DatabaseReference for this connection.
 Connection getJdbcConnection()
          Gets the underlying JDBC connection.
 void incrementTransactionCount()
          Increments the underlying TransactionCounter by one.
protected  boolean isJdbcConnection(Connection connection)
          Compare the underlying JDBC connection with another.
 void prepareForTransactions()
          Prepares the underlying TransactionCounter prior to any edits.
 void rollback()
          Handles the rollback for the transaction.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedConnection

protected ManagedConnection(DatabaseReference databaseReference)
                     throws ClassNotFoundException,
                            NamingException,
                            SQLException
Construct based upon a supplied DatabaseReference.

During construction, a JDBC connection is established based upon the associated with a DatabaseReference.

Parameters:
databaseReference - the associated DatabaseReference
Throws:
ClassNotFoundException - if the database driver class was not found
NamingException - if a JNDI naming exception occurs
SQLException - if an SQL exception occurs while establishing the connection
Method Detail

getJdbcConnection

public Connection getJdbcConnection()
Gets the underlying JDBC connection.

Returns:
the underlying JDBC connection

getDatabaseReference

protected DatabaseReference getDatabaseReference()
Gets the DatabaseReference for this connection.

Returns:
the associated DatabaseReference

close

protected void close()
Closes the underlying JDBC connection.
The underlying TransactionCounter is reset.


commit

public void commit()
            throws SQLException
Handles the commit for the transaction.
If this ManagedConnection was not prepared for transactions, no commit is executed.
If the underlying transaction count is zero, no commit is executed.

Throws:
SQLException - if an exception occurs

finalize

protected void finalize()
                 throws Throwable
Finalize on garbage collection.

Overrides:
finalize in class Object
Throws:
Throwable

incrementTransactionCount

public void incrementTransactionCount()
Increments the underlying TransactionCounter by one.


isJdbcConnection

protected boolean isJdbcConnection(Connection connection)
Compare the underlying JDBC connection with another.

Parameters:
connection - the connection to compare
Returns:
true if the underlying JDBC connection == the passed connection

prepareForTransactions

public void prepareForTransactions()
                            throws SQLException
Prepares the underlying TransactionCounter prior to any edits.
Auto commit is set to false for the underlying JDBC connection.
This method must be executed prior to any commit or rollback.

Throws:
SQLException - if an exception occurs

rollback

public void rollback()
Handles the rollback for the transaction.
A single rolback is executed for each incremented transaction count.
If this ManagedConnection was not prepared for transactions, no rollback is executed.


getClobMutator

public IClobMutator getClobMutator()
                            throws SQLException
Gets clob mutator.

Returns:
clob mutator
Throws:
SQLException - if error getting clob mutator

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.