org.datanucleus.store.rdbms
Class JDOConnectionImpl

java.lang.Object
  extended by org.datanucleus.api.jdo.JDOConnectionImpl
      extended by org.datanucleus.store.rdbms.JDOConnectionImpl
All Implemented Interfaces:
Connection, Wrapper, javax.jdo.datastore.JDOConnection, org.datanucleus.store.NucleusConnection

public final class JDOConnectionImpl
extends org.datanucleus.api.jdo.JDOConnectionImpl
implements Connection, org.datanucleus.store.NucleusConnection

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


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation utility for output messages
 
Fields inherited from class org.datanucleus.api.jdo.JDOConnectionImpl
nucConn
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
JDOConnectionImpl(org.datanucleus.store.NucleusConnection nconn)
          Constructor.
 
Method Summary
 void abort(Executor executor)
           
 void assertAvailable()
          Assert the JDOConnection is available
 void clearWarnings()
          Method to clear warnings from the connection.
 void commit()
          Method to commit the connection.
 Array createArrayOf(String typeName, Object[] elements)
           
 Blob createBlob()
           
 Clob createClob()
           
 NClob createNClob()
           
 SQLXML createSQLXML()
           
 Statement createStatement()
          Accessor for a statement.
 Statement createStatement(int resultSetType, int resultSetConcurrency)
          Accessor for a statement.
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Accessor for a statement.
 Struct createStruct(String typeName, Object[] attributes)
           
 boolean getAutoCommit()
          Accessor for the autocommit setting.
 String getCatalog()
          Accessor for the catalog.
 Properties getClientInfo()
           
 String getClientInfo(String name)
           
 int getHoldability()
          Access the holdability of the connection.
 DatabaseMetaData getMetaData()
          Accessor for the database metadata.
 int getNetworkTimeout()
           
 String getSchema()
           
 int getTransactionIsolation()
          Accessor for the transaction isolation level.
 Map getTypeMap()
          Accessor for the type map.
 SQLWarning getWarnings()
          Accessor for the warnings.
 boolean isAvailable()
           
 boolean isClosed()
          Accessor for whether the connection is closed.
 boolean isReadOnly()
          Accessor for whether the connection is read only.
 boolean isValid(int timeout)
           
 boolean isWrapperFor(Class iface)
           
 String nativeSQL(String sql)
          Accessor for using native SQL.
 CallableStatement prepareCall(String sql)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
           
 CallableStatement prepareCall(String arg0, int arg1, int arg2, int arg3)
           
 PreparedStatement prepareStatement(String sql)
           
 PreparedStatement prepareStatement(String arg0, int arg1)
           
 PreparedStatement prepareStatement(String arg0, int[] arg1)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
           
 PreparedStatement prepareStatement(String arg0, int arg1, int arg2, int arg3)
           
 PreparedStatement prepareStatement(String arg0, String[] arg1)
           
 void releaseSavepoint(Savepoint pt)
          Mutator to release the savepoint.
 void rollback()
          Method to rollback the connection.
 void rollback(Savepoint pt)
          Mutator to rollback the savepoint.
 void setAutoCommit(boolean autoCommit)
          Method to set the autocommit for the connection.
 void setCatalog(String catalog)
          Mutator for the catalog
 void setClientInfo(Properties properties)
           
 void setClientInfo(String name, String value)
           
 void setHoldability(int holdability)
          Method to set the holdability for the connection.
 void setNetworkTimeout(Executor executor, int milliseconds)
           
 void setReadOnly(boolean readOnly)
          Method to set the read-only nature for the connection.
 Savepoint setSavepoint()
          Mutator to set the savepoint.
 Savepoint setSavepoint(String arg0)
           
 void setSchema(String schema)
           
 void setTransactionIsolation(int level)
          Method to set the transaction isolation for the connection.
 void setTypeMap(Map map)
          Method to set the type map
 Object unwrap(Class iface)
           
 
Methods inherited from class org.datanucleus.api.jdo.JDOConnectionImpl
close, getNativeConnection, throwExceptionNotAvailable, throwExceptionUnsupportedOperation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
close
 
Methods inherited from interface org.datanucleus.store.NucleusConnection
close, getNativeConnection
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

JDOConnectionImpl

public JDOConnectionImpl(org.datanucleus.store.NucleusConnection nconn)
Constructor.

Parameters:
nconn - The Nucleus Connection delegate
Method Detail

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface org.datanucleus.store.NucleusConnection

getHoldability

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

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

getTransactionIsolation

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

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

clearWarnings

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

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

commit

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

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

rollback

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

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

getAutoCommit

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

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

isClosed

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

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

isReadOnly

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

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

setHoldability

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

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

setTransactionIsolation

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

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

setAutoCommit

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

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

setReadOnly

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

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

getCatalog

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

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

setCatalog

public void setCatalog(String catalog)
                throws SQLException
Mutator for the catalog

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

getMetaData

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

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

getWarnings

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

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

setSavepoint

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

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

releaseSavepoint

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

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

rollback

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

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

createStatement

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

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

createStatement

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

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

createStatement

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

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

getTypeMap

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

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

setTypeMap

public void setTypeMap(Map map)
                throws SQLException
Method to set the type map

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

nativeSQL

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

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

prepareCall

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

prepareCall

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

prepareCall

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

prepareStatement

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

prepareStatement

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

prepareStatement

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

prepareStatement

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

prepareStatement

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

setSavepoint

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

prepareStatement

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

assertAvailable

public void assertAvailable()
Assert the JDOConnection is available

Throws:
Exception - if the connection is no longer available

createArrayOf

public Array createArrayOf(String typeName,
                           Object[] elements)
                    throws SQLException
Specified by:
createArrayOf in interface Connection
Throws:
SQLException

createBlob

public Blob createBlob()
                throws SQLException
Specified by:
createBlob in interface Connection
Throws:
SQLException

createClob

public Clob createClob()
                throws SQLException
Specified by:
createClob in interface Connection
Throws:
SQLException

createStruct

public Struct createStruct(String typeName,
                           Object[] attributes)
                    throws SQLException
Specified by:
createStruct in interface Connection
Throws:
SQLException

getClientInfo

public Properties getClientInfo()
                         throws SQLException
Specified by:
getClientInfo in interface Connection
Throws:
SQLException

getClientInfo

public String getClientInfo(String name)
                     throws SQLException
Specified by:
getClientInfo in interface Connection
Throws:
SQLException

isValid

public boolean isValid(int timeout)
                throws SQLException
Specified by:
isValid in interface Connection
Throws:
SQLException

setClientInfo

public void setClientInfo(Properties properties)
                   throws SQLClientInfoException
Specified by:
setClientInfo in interface Connection
Throws:
SQLClientInfoException

setClientInfo

public void setClientInfo(String name,
                          String value)
                   throws SQLClientInfoException
Specified by:
setClientInfo in interface Connection
Throws:
SQLClientInfoException

createNClob

public NClob createNClob()
                  throws SQLException
Specified by:
createNClob in interface Connection
Throws:
SQLException

createSQLXML

public SQLXML createSQLXML()
                    throws SQLException
Specified by:
createSQLXML in interface Connection
Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Throws:
SQLException

unwrap

public Object unwrap(Class iface)
              throws SQLException
Specified by:
unwrap in interface Wrapper
Throws:
SQLException

setSchema

public void setSchema(String schema)
               throws SQLException
Throws:
SQLException

getSchema

public String getSchema()
                 throws SQLException
Throws:
SQLException

abort

public void abort(Executor executor)
           throws SQLException
Throws:
SQLException

setNetworkTimeout

public void setNetworkTimeout(Executor executor,
                              int milliseconds)
                       throws SQLException
Throws:
SQLException

getNetworkTimeout

public int getNetworkTimeout()
                      throws SQLException
Throws:
SQLException


Copyright © 2012. All Rights Reserved.