Package org.datanucleus.api.jdo
Class JDOConnectionJDBCImpl
- java.lang.Object
-
- org.datanucleus.api.jdo.JDOConnectionImpl
-
- org.datanucleus.api.jdo.JDOConnectionJDBCImpl
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
,javax.jdo.datastore.JDOConnection
public class JDOConnectionJDBCImpl extends JDOConnectionImpl implements java.sql.Connection
Implementation of a JDO connection that is also a wrapper for "java.sql.Connection".
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.Connection
conn
The JDBC connection (shortcut for the native connection of the NucleusConnection).private boolean
isAvailable
whether this connection is available to the developer-
Fields inherited from class org.datanucleus.api.jdo.JDOConnectionImpl
nucConn
-
-
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(java.util.concurrent.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.java.sql.Array
createArrayOf(java.lang.String typeName, java.lang.Object[] elements)
java.sql.Blob
createBlob()
java.sql.Clob
createClob()
java.sql.NClob
createNClob()
java.sql.SQLXML
createSQLXML()
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.java.sql.Struct
createStruct(java.lang.String typeName, java.lang.Object[] attributes)
boolean
getAutoCommit()
Accessor for the autocommit setting.java.lang.String
getCatalog()
Accessor for the catalog.java.util.Properties
getClientInfo()
java.lang.String
getClientInfo(java.lang.String name)
int
getHoldability()
Access the holdability of the connection.java.sql.DatabaseMetaData
getMetaData()
Accessor for the database metadata.int
getNetworkTimeout()
java.lang.String
getSchema()
int
getTransactionIsolation()
Accessor for the transaction isolation level.java.util.Map<java.lang.String,java.lang.Class<?>>
getTypeMap()
Accessor for the type map.java.sql.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(java.lang.Class iface)
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 catalogvoid
setClientInfo(java.lang.String name, java.lang.String value)
void
setClientInfo(java.util.Properties properties)
void
setHoldability(int holdability)
Method to set the holdability for the connection.void
setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)
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
setSchema(java.lang.String schema)
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<T> T
unwrap(java.lang.Class<T> iface)
-
Methods inherited from class org.datanucleus.api.jdo.JDOConnectionImpl
close, getNativeConnection, throwExceptionNotAvailable, throwExceptionUnsupportedOperation
-
-
-
-
Method Detail
-
isAvailable
public boolean isAvailable()
-
getHoldability
public int getHoldability() throws java.sql.SQLException
Access the holdability of the connection.- Specified by:
getHoldability
in interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
- thrown if there is a problem
-
commit
public void commit() throws java.sql.SQLException
Method to commit the connection.- Specified by:
commit
in interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Parameters:
resultSetType
- type of resultsresultSetConcurrency
- 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 interfacejava.sql.Connection
- Parameters:
resultSetType
- type of resultsresultSetConcurrency
- The concurrencyresultSetHoldability
- The holdability- Returns:
- The statement
- Throws:
java.sql.SQLException
- Thrown if an error occurs
-
getTypeMap
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException
Accessor for the type map.- Specified by:
getTypeMap
in interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String arg0) throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
assertAvailable
public void assertAvailable()
Assert the JDOConnection is available. Throws a JDOException if not available
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException
- Specified by:
createArrayOf
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException
- Specified by:
createBlob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException
- Specified by:
createClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException
- Specified by:
createStruct
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException
- Specified by:
isValid
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException
- Specified by:
createNClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException
- Specified by:
createSQLXML
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class iface) throws java.sql.SQLException
- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException
- Specified by:
setSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException
- Specified by:
getSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
- Specified by:
abort
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException
- Specified by:
setNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException
- Specified by:
getNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
-