org.jpox
Class JDOConnectionImpl

java.lang.Object
  extended byorg.jpox.JDOConnectionImpl
All Implemented Interfaces:
java.sql.Connection, javax.jdo.datastore.JDOConnection

public final class JDOConnectionImpl
extends java.lang.Object
implements java.sql.Connection, javax.jdo.datastore.JDOConnection

Implementation of a JDO connection for RDBMS datastores. Provides a wrapper to a java.sql.Connection in this implementation.

Version:
$Revision: 1.12 $

Field Summary
protected static Localiser LOCALISER
          Localisation utility for output messages
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
JDOConnectionImpl(java.sql.Connection conn, java.lang.Runnable onClose)
          Constructor.
 
Method Summary
 void assertAvailable()
          Assert the JDOConnection is available
 void clearWarnings()
          Method to clear warnings from the connection.
 void close()
          Method to close the connection.
 void commit()
          Method to commit the connection.
 java.sql.Statement createStatement()
          Accessor for a statement.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Accessor for a statement.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Accessor for a statement.
 boolean getAutoCommit()
          Accessor for the autocommit setting.
 java.lang.String getCatalog()
          Accessor for the catalog.
 int getHoldability()
          Access the holdability of the connection.
 java.sql.DatabaseMetaData getMetaData()
          Accessor for the database metadata.
 java.lang.Object getNativeConnection()
           
 int getTransactionIsolation()
          Accessor for the transaction isolation level.
 java.util.Map getTypeMap()
          Accessor for the type map.
 java.sql.SQLWarning getWarnings()
          Accessor for the warnings.
 boolean isClosed()
          Accessor for whether the connection is closed.
 boolean isReadOnly()
          Accessor for whether the connection is read only.
 java.lang.String nativeSQL(java.lang.String sql)
          Accessor for using native SQL.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 java.sql.CallableStatement prepareCall(java.lang.String arg0, int arg1, int arg2, int arg3)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int arg1)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int[] arg1)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int arg1, int arg2, int arg3)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, java.lang.String[] arg1)
           
 void releaseSavepoint(java.sql.Savepoint pt)
          Mutator to release the savepoint.
 void rollback()
          Method to rollback the connection.
 void rollback(java.sql.Savepoint pt)
          Mutator to rollback the savepoint.
 void setAutoCommit(boolean autoCommit)
          Method to set the autocommit for the connection.
 void setCatalog(java.lang.String catalog)
          Mutator for the catalog
 void setHoldability(int holdability)
          Method to set the holdability for the connection.
 void setReadOnly(boolean readOnly)
          Method to set the read-only nature for the connection.
 java.sql.Savepoint setSavepoint()
          Mutator to set the savepoint.
 java.sql.Savepoint setSavepoint(java.lang.String arg0)
           
 void setTransactionIsolation(int level)
          Method to set the transaction isolation for the connection.
 void setTypeMap(java.util.Map map)
          Method to set the type map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

JDOConnectionImpl

public JDOConnectionImpl(java.sql.Connection conn,
                         java.lang.Runnable onClose)
Constructor.

Parameters:
conn - the connection
onClose - the Runnable operation that will be called at user call to close()
Method Detail

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Access the holdability of the connection.

Specified by:
getHoldability in interface java.sql.Connection
Returns:
The holdability
Throws:
java.sql.SQLException - if there is a problem

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Accessor for the transaction isolation level.

Specified by:
getTransactionIsolation in interface java.sql.Connection
Returns:
The isolation level
Throws:
java.sql.SQLException - if there is a problem

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Method to clear warnings from the connection.

Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - thrown if there is a problem

close

public void close()
Method to close the connection.

Specified by:
close in interface java.sql.Connection

commit

public void commit()
            throws java.sql.SQLException
Method to commit the connection.

Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - thrown if an error occurs.

rollback

public void rollback()
              throws java.sql.SQLException
Method to rollback the connection.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - thrown if an error occurs.

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Accessor for the autocommit setting.

Specified by:
getAutoCommit in interface java.sql.Connection
Returns:
Whether to autocommit
Throws:
java.sql.SQLException - thrown if an error occurs.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Accessor for whether the connection is closed.

Specified by:
isClosed in interface java.sql.Connection
Returns:
Whether it is closed.
Throws:
java.sql.SQLException - thrown if an error occurs.

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Accessor for whether the connection is read only.

Specified by:
isReadOnly in interface java.sql.Connection
Returns:
Whether it is read only.
Throws:
java.sql.SQLException - thrown if an error occurs.

setHoldability

public void setHoldability(int holdability)
                    throws java.sql.SQLException
Method to set the holdability for the connection.

Specified by:
setHoldability in interface java.sql.Connection
Parameters:
holdability - The holdability
Throws:
java.sql.SQLException - thrown if an error occurs.

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
Method to set the transaction isolation for the connection.

Specified by:
setTransactionIsolation in interface java.sql.Connection
Parameters:
level - The transaction isolation
Throws:
java.sql.SQLException - thrown if an error occurs.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Method to set the autocommit for the connection.

Specified by:
setAutoCommit in interface java.sql.Connection
Parameters:
autoCommit - Whether to autocommit
Throws:
java.sql.SQLException - thrown if an error occurs.

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
Method to set the read-only nature for the connection.

Specified by:
setReadOnly in interface java.sql.Connection
Parameters:
readOnly - whether it is read-only
Throws:
java.sql.SQLException - thrown if an error occurs.

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Accessor for the catalog.

Specified by:
getCatalog in interface java.sql.Connection
Returns:
The catalog
Throws:
java.sql.SQLException - Thrown if an error occurs

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
Mutator for the catalog

Specified by:
setCatalog in interface java.sql.Connection
Parameters:
catalog - The catalog
Throws:
java.sql.SQLException - Thrown if an error occurs

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
Accessor for the database metadata.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
The database metadata
Throws:
java.sql.SQLException - Thrown if an error occurs

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Accessor for the warnings.

Specified by:
getWarnings in interface java.sql.Connection
Returns:
The warnings
Throws:
java.sql.SQLException - Thrown if an error occurs

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Mutator to set the savepoint.

Specified by:
setSavepoint in interface java.sql.Connection
Returns:
The savepoint
Throws:
java.sql.SQLException - Thrown if an error occurs

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint pt)
                      throws java.sql.SQLException
Mutator to release the savepoint.

Specified by:
releaseSavepoint in interface java.sql.Connection
Parameters:
pt - The savepoint
Throws:
java.sql.SQLException - Thrown if an error occurs

rollback

public void rollback(java.sql.Savepoint pt)
              throws java.sql.SQLException
Mutator to rollback the savepoint.

Specified by:
rollback in interface java.sql.Connection
Parameters:
pt - The savepoint
Throws:
java.sql.SQLException - Thrown if an error occurs

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Accessor for a statement.

Specified by:
createStatement in interface java.sql.Connection
Returns:
The statement
Throws:
java.sql.SQLException - Thrown if an error occurs

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Accessor for a statement.

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - type of results
resultSetConcurrency - The concurrency
Returns:
The statement
Throws:
java.sql.SQLException - Thrown if an error occurs

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws java.sql.SQLException
Accessor for a statement.

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - type of results
resultSetConcurrency - The concurrency
resultSetHoldability - The holdability
Returns:
The statement
Throws:
java.sql.SQLException - Thrown if an error occurs

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Accessor for the type map.

Specified by:
getTypeMap in interface java.sql.Connection
Returns:
The type map
Throws:
java.sql.SQLException - Thrown if an error occurs

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Method to set the type map

Specified by:
setTypeMap in interface java.sql.Connection
Parameters:
map - The type map
Throws:
java.sql.SQLException - Thrown if an error occurs

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Accessor for using native SQL.

Specified by:
nativeSQL in interface java.sql.Connection
Parameters:
sql - The sql
Returns:
The native SQL
Throws:
java.sql.SQLException - Thrown if an error occurs

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String arg0,
                                              int arg1,
                                              int arg2,
                                              int arg3)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int arg1,
                                                   int arg2,
                                                   int arg3)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int[] arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String arg0)
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   java.lang.String[] arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

assertAvailable

public void assertAvailable()
Assert the JDOConnection is available

Throws:
javax.jdo.JDOUserException - if the connection is no longer available

getNativeConnection

public java.lang.Object getNativeConnection()
Specified by:
getNativeConnection in interface javax.jdo.datastore.JDOConnection


Copyright © -2007 . All Rights Reserved.