Package org.datanucleus.api.jdo
Class JDOConnectionJDBCImpl
- java.lang.Object
-
- org.datanucleus.api.jdo.JDOConnectionImpl
-
- org.datanucleus.api.jdo.JDOConnectionJDBCImpl
-
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
,javax.jdo.datastore.JDOConnection
public class JDOConnectionJDBCImpl extends JDOConnectionImpl implements Connection
Implementation of a JDO connection that is also a wrapper for "java.sql.Connection".
-
-
Field Summary
-
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
Constructors Constructor Description JDOConnectionJDBCImpl(org.datanucleus.store.NucleusConnection nconn)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 catalogvoid
setClientInfo(String name, String value)
void
setClientInfo(Properties properties)
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 mapObject
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
beginRequest, close, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
-
-
-
Method Detail
-
isAvailable
public boolean isAvailable()
-
getHoldability
public int getHoldability() throws SQLException
Access the holdability of the connection.- Specified by:
getHoldability
in interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- Throws:
SQLException
- thrown if there is a problem
-
commit
public void commit() throws SQLException
Method to commit the connection.- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
- thrown if an error occurs.
-
rollback
public void rollback() throws SQLException
Method to rollback the connection.- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
- thrown if an error occurs.
-
getAutoCommit
public boolean getAutoCommit() throws SQLException
Accessor for the autocommit setting.- Specified by:
getAutoCommit
in interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- Parameters:
resultSetType
- type of resultsresultSetConcurrency
- 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 interfaceConnection
- Parameters:
resultSetType
- type of resultsresultSetConcurrency
- The concurrencyresultSetHoldability
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- 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 interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String arg0, int arg1, int arg2, int arg3) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String arg0, int arg1) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String arg0, int arg1, int arg2, int arg3) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String arg0, int[] arg1) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String arg0) throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String arg0, String[] arg1) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
assertAvailable
public void assertAvailable()
Assert the JDOConnection is available. Throws a JDOException if not available
-
createArrayOf
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createBlob
public Blob createBlob() throws SQLException
- Specified by:
createBlob
in interfaceConnection
- Throws:
SQLException
-
createClob
public Clob createClob() throws SQLException
- Specified by:
createClob
in interfaceConnection
- Throws:
SQLException
-
createStruct
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
createNClob
public NClob createNClob() throws SQLException
- Specified by:
createNClob
in interfaceConnection
- Throws:
SQLException
-
createSQLXML
public SQLXML createSQLXML() throws SQLException
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
public Object unwrap(Class iface) throws SQLException
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
setSchema
public void setSchema(String schema) throws SQLException
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
getSchema
public String getSchema() throws SQLException
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws SQLException
- Specified by:
getNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
-