Class ConnectionImpl
- java.lang.Object
-
- org.teiid.jdbc.WrapperImpl
-
- org.teiid.jdbc.ConnectionImpl
-
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
,TeiidConnection
public class ConnectionImpl extends WrapperImpl implements TeiidConnection
Teiid's Connection implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ISOLATION
protected Properties
propInfo
protected ServerConnection
serverConn
-
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 ConnectionImpl(ServerConnection serverConn, Properties info, String url)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abort(Executor executor)
void
cancelRequest(String id)
Cancel the requestvoid
changeUser(String userName, String newPassword)
Re-authenticate with the given username and password.void
clearWarnings()
void
close()
void
commit()
This method makes any changes involved in a transaction permanent and releases any locks held by the connection object.protected void
commitTransaction(XidImpl arg0, boolean arg1)
Array
createArrayOf(String typeName, Object[] elements)
Blob
createBlob()
Clob
createClob()
NClob
createNClob()
SQLXML
createSQLXML()
StatementImpl
createStatement()
StatementImpl
createStatement(int resultSetType, int resultSetConcurrency)
StatementImpl
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Struct
createStruct(String typeName, Object[] attributes)
protected void
endTransaction(XidImpl arg0, int arg1)
protected void
forgetTransaction(XidImpl arg0)
Collection<Annotation>
getAnnotations()
boolean
getAutoCommit()
String
getCatalog()
Properties
getClientInfo()
String
getClientInfo(String name)
String
getConnectionId()
Connection identifier of this connectionProperties
getConnectionProps()
PlanNode
getCurrentPlanDescription()
String
getDatabaseName()
Get the database name that this connection is representingString
getDebugLog()
protected Properties
getExecutionProperties()
String
getExecutionProperty(String key)
int
getHoldability()
DatabaseMetaDataImpl
getMetaData()
int
getNetworkTimeout()
Properties
getPayload()
String
getSchema()
ServerConnection
getServerConnection()
This method gets the ServerConnection object wrapped by this object.int
getTransactionIsolation()
protected XidImpl
getTransactionXid()
Map<String,Class<?>>
getTypeMap()
int
getVDBVersion()
Deprecated.SQLWarning
getWarnings()
This method will return the first warning reported by calls on this connection, or null if none exist.boolean
isClosed()
This method will return whether this connection is closed or not.boolean
isReadOnly()
boolean
isSameProcess(ConnectionImpl conn)
boolean
isValid(int timeout)
String
nativeSQL(String sql)
protected long
nextRequestID()
Generate the next unique requestID for matching up requests with responses.CallableStatementImpl
prepareCall(String sql)
Creates a CallableStatement object that contains sql and that will produce ResultSet objects that are non-scrollable and non-updatable.CallableStatementImpl
prepareCall(String sql, int resultSetType, int resultSetConcurrency)
CallableStatementImpl
prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatementImpl
prepareStatement(String sql)
PreparedStatement
prepareStatement(String sql, int autoGeneratedKeys)
PreparedStatement
prepareStatement(String sql, int[] columnIndexes)
PreparedStatementImpl
prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
PreparedStatementImpl
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatementImpl
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys)
PreparedStatement
prepareStatement(String sql, String[] columnNames)
protected int
prepareTransaction(XidImpl arg0)
protected Xid[]
recoverTransaction(int arg0)
void
recycleConnection()
void
releaseSavepoint(Savepoint savepoint)
void
restoreTransactionCharacteristics()
void
rollback()
void
rollback(boolean startTxn)
Rollback the current local transactionvoid
rollback(Savepoint savepoint)
protected void
rollbackTransaction(XidImpl arg0)
void
saveTransactionCharacteristics()
void
setAnnotations(Collection<Annotation> annotations)
void
setAutoCommit(boolean autoCommit)
void
setCatalog(String catalog)
Teiid does not allow setting a catalog through a connection.void
setClientInfo(String name, String value)
void
setClientInfo(Properties properties)
void
setCurrentPlanDescription(PlanNode currentPlanDescription)
void
setDebugLog(String debugLog)
void
setExecutionProperty(String key, String value)
void
setHoldability(int holdability)
void
setInLocalTxn(boolean inLocalTxn)
void
setNetworkTimeout(Executor executor, int milliseconds)
void
setPayload(Properties payload)
void
setReadOnly(boolean readOnly)
Savepoint
setSavepoint()
Savepoint
setSavepoint(String name)
void
setSchema(String schema)
void
setTransactionIsolation(int level)
void
setTypeMap(Map<String,Class<?>> map)
protected void
startTransaction(XidImpl arg0, int arg1, int timeout)
ResultsFuture<?>
submitSetAutoCommitTrue(boolean commit)
-
Methods inherited from class org.teiid.jdbc.WrapperImpl
isWrapperFor, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Field Detail
-
DEFAULT_ISOLATION
public static final int DEFAULT_ISOLATION
- See Also:
- Constant Field Values
-
propInfo
protected Properties propInfo
-
serverConn
protected ServerConnection serverConn
-
-
Constructor Detail
-
ConnectionImpl
public ConnectionImpl(ServerConnection serverConn, Properties info, String url)
-
-
Method Detail
-
getAnnotations
public Collection<Annotation> getAnnotations()
-
setAnnotations
public void setAnnotations(Collection<Annotation> annotations)
-
getDebugLog
public String getDebugLog()
-
setDebugLog
public void setDebugLog(String debugLog)
-
getCurrentPlanDescription
public PlanNode getCurrentPlanDescription()
-
setCurrentPlanDescription
public void setCurrentPlanDescription(PlanNode currentPlanDescription)
-
getExecutionProperties
protected Properties getExecutionProperties()
-
getConnectionId
public String getConnectionId()
Connection identifier of this connection- Returns:
- identifier
-
nextRequestID
protected long nextRequestID()
Generate the next unique requestID for matching up requests with responses. These IDs should be unique only in the context of a ServerConnection instance.- Returns:
- Request ID
-
cancelRequest
public void cancelRequest(String id) throws TeiidProcessingException, TeiidComponentException
Cancel the request
-
clearWarnings
public void clearWarnings() throws SQLException
- Specified by:
clearWarnings
in interfaceConnection
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
-
commit
public void commit() throws SQLException
This method makes any changes involved in a transaction permanent and releases any locks held by the connection object. This is only used when auto-commit is set to false.
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
- if the transaction had been rolled back or marked to roll back.
-
createStatement
public StatementImpl createStatement() throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStatement
public StatementImpl createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException
- Specified by:
getAutoCommit
in interfaceConnection
- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalog
in interfaceConnection
- Throws:
SQLException
-
getServerConnection
public ServerConnection getServerConnection() throws SQLException
This method gets the ServerConnection object wrapped by this object.
- Returns:
- ServerConnection object
- Throws:
SQLException
-
getVDBVersion
@Deprecated public int getVDBVersion() throws SQLException
Deprecated.- Throws:
SQLException
-
getMetaData
public DatabaseMetaDataImpl getMetaData() throws SQLException
- Specified by:
getMetaData
in interfaceConnection
- Throws:
SQLException
-
getDatabaseName
public String getDatabaseName()
Get the database name that this connection is representing- Returns:
- String name of the database
-
getHoldability
public int getHoldability() throws SQLException
- Specified by:
getHoldability
in interfaceConnection
- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws SQLException
- Specified by:
getTypeMap
in interfaceConnection
- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
This method will return the first warning reported by calls on this connection, or null if none exist.
- Specified by:
getWarnings
in interfaceConnection
- Returns:
- A SQLWarning object if there are any warnings.
- Throws:
SQLException
- should never occur
-
isClosed
public boolean isClosed() throws SQLException
This method will return whether this connection is closed or not.
- Specified by:
isClosed
in interfaceConnection
- Returns:
- booleanvalue indicating if the connection is closed
- Throws:
SQLException
- should never occur
-
isReadOnly
public boolean isReadOnly() throws SQLException
- Specified by:
isReadOnly
in interfaceConnection
- Throws:
SQLException
-
nativeSQL
public String nativeSQL(String sql) throws SQLException
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatementImpl prepareCall(String sql) throws SQLException
Creates a CallableStatement object that contains sql and that will produce ResultSet objects that are non-scrollable and non-updatable. A SQL stored procedure call statement is handled by creating a CallableStatement for it.
- Specified by:
prepareCall
in interfaceConnection
- Parameters:
sql
- String(escape syntax) for invoking a stored procedure.- Returns:
- CallableStatement object that can be used to execute the storedProcedure
- Throws:
SQLException
- if there is an error creating the callable statement object
-
prepareCall
public CallableStatementImpl prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatementImpl prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys) throws SQLException
- Parameters:
sql
-resultSetType
-resultSetConcurrency
-resultSetHoldability
-autoGeneratedKeys
-- Returns:
- Throws:
SQLException
-
prepareStatement
public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
rollback
public void rollback() throws SQLException
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
rollback
public void rollback(boolean startTxn) throws SQLException
Rollback the current local transaction- Parameters:
startTxn
-- Throws:
SQLException
-
submitSetAutoCommitTrue
public ResultsFuture<?> submitSetAutoCommitTrue(boolean commit) throws SQLException
- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws SQLException
- Specified by:
setAutoCommit
in interfaceConnection
- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
Teiid does not allow setting a catalog through a connection. This method silently ignores the request as per the specification.
- Specified by:
setCatalog
in interfaceConnection
- Parameters:
catalog
-- Throws:
SQLException
- This should never occur.
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException
- Specified by:
setReadOnly
in interfaceConnection
- Throws:
SQLException
-
commitTransaction
protected void commitTransaction(XidImpl arg0, boolean arg1) throws SQLException
- Throws:
SQLException
-
endTransaction
protected void endTransaction(XidImpl arg0, int arg1) throws SQLException
- Throws:
SQLException
-
forgetTransaction
protected void forgetTransaction(XidImpl arg0) throws SQLException
- Throws:
SQLException
-
prepareTransaction
protected int prepareTransaction(XidImpl arg0) throws SQLException
- Throws:
SQLException
-
recoverTransaction
protected Xid[] recoverTransaction(int arg0) throws SQLException
- Throws:
SQLException
-
rollbackTransaction
protected void rollbackTransaction(XidImpl arg0) throws SQLException
- Throws:
SQLException
-
startTransaction
protected void startTransaction(XidImpl arg0, int arg1, int timeout) throws SQLException
- Throws:
SQLException
-
getTransactionXid
protected XidImpl getTransactionXid()
-
isValid
public boolean isValid(int timeout) throws SQLException
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
recycleConnection
public void recycleConnection()
-
isSameProcess
public boolean isSameProcess(ConnectionImpl conn) throws CommunicationException
- Throws:
CommunicationException
-
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
-
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
-
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
-
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
-
createStatement
public StatementImpl createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStruct
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatementImpl prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException
- Specified by:
setHoldability
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws SQLException
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
changeUser
public void changeUser(String userName, String newPassword) throws SQLException
Description copied from interface:TeiidConnection
Re-authenticate with the given username and password. If the re-authentication fails the connection will remain under the current user.- Specified by:
changeUser
in interfaceTeiidConnection
- Parameters:
userName
- the username to authenticate withnewPassword
- the password to authenticate with- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws SQLException
- Specified by:
getNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getSchema
public String getSchema() throws SQLException
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
setSchema
public void setSchema(String schema) throws SQLException
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
getPayload
public Properties getPayload()
-
setPayload
public void setPayload(Properties payload)
-
getConnectionProps
public Properties getConnectionProps()
-
setInLocalTxn
public void setInLocalTxn(boolean inLocalTxn)
-
saveTransactionCharacteristics
public void saveTransactionCharacteristics()
-
restoreTransactionCharacteristics
public void restoreTransactionCharacteristics()
-
-