Methods Summary |
---|
public void | afterJTSTransaction()To be called after JTS transaction has been completed (committed or rolled back)
if (usesExternalTransactionController()) {
setIsInTransaction(false);
if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) {
closeConnection();
setDatasourceConnection(null);
}
}
|
protected abstract void | basicBeginTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Begin the driver level transaction.
|
protected abstract void | basicCommitTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Commit the driver level transaction.
|
protected abstract java.lang.Object | basicExecuteCall(oracle.toplink.essentials.queryframework.Call call, oracle.toplink.essentials.internal.sessions.AbstractRecord row, oracle.toplink.essentials.internal.sessions.AbstractSession session)Execute the call to driver level datasource.
|
protected abstract void | basicRollbackTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Rollback the driver level transaction.
|
public void | beginTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Begin a transaction on the database. If not using managed transaction begin a local transaction.
if (usesExternalTransactionController()) {
setIsInTransaction(true);
return;
}
session.log(SessionLog.FINER, SessionLog.TRANSACTION, "begin_transaction", (Object[])null, this);
try {
session.startOperationProfile(SessionProfiler.TRANSACTION);
incrementCallCount(session);
basicBeginTransaction(session);
setIsInTransaction(true);
} finally {
decrementCallCount();
session.endOperationProfile(SessionProfiler.TRANSACTION);
}
|
protected abstract void | buildConnectLog(oracle.toplink.essentials.internal.sessions.AbstractSession session)Build a log string of any driver metadata that can be obtained.
|
public java.lang.Object | clone()Clone the accessor.
try {
DatasourceAccessor accessor = (DatasourceAccessor)super.clone();
return accessor;
} catch (CloneNotSupportedException exception) {
throw new InternalError("clone not supported");
}
|
public void | closeConnection()Close the accessor's connection.
This is used only for external connection pooling
when it is intended for the connection to be reconnected in the future.
try {
if (getDatasourceConnection() != null) {
if (isDatasourceConnected()) {
closeDatasourceConnection();
}
setDatasourceConnection(null);
}
} catch (DatabaseException exception) {
// Ignore
setDatasourceConnection(null);
}
|
protected abstract void | closeDatasourceConnection()Close the connection to the driver level datasource.
|
public void | commitTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Commit a transaction on the database. If using non-managed transaction commit the local transaction.
if (usesExternalTransactionController()) {
// if there is no external TX controller, then that means we are currently not synchronized
// with a global JTS transaction. In this case, there won't be any 'afterCompletion'
// callbacks so we have to release the connection here. It is possible (WLS 5.1) to choose
// 'usesExternalTransactionController' on the login, but still acquire a uow that WON'T be
// synchronized with a global TX.
if (session.getExternalTransactionController() == null) {
setIsInTransaction(false);
if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) {
closeConnection();
setDatasourceConnection(null);
}
}
return;
}
session.log(SessionLog.FINER, SessionLog.TRANSACTION, "commit_transaction", (Object[])null, this);
try {
session.startOperationProfile(SessionProfiler.TRANSACTION);
incrementCallCount(session);
basicCommitTransaction(session);
// true=="committed"; false=="not jts transactioin"
session.afterTransaction(true, false);
setIsInTransaction(false);
} finally {
decrementCallCount();
session.endOperationProfile(SessionProfiler.TRANSACTION);
}
|
protected void | connect(oracle.toplink.essentials.sessions.Login login)Connect to the database.
Exceptions are caught and re-thrown as TopLink exceptions.
setDatasourceConnection(login.connectToDatasource(this));
setIsConnected(true);
|
public void | connect(oracle.toplink.essentials.sessions.Login login, oracle.toplink.essentials.internal.sessions.AbstractSession session)Connect to the datasource. Through using a CCI ConnectionFactory.
Catch exceptions and re-throw as TopLink exceptions.
session.startOperationProfile(SessionProfiler.CONNECT);
session.incrementProfile(SessionProfiler.TlConnects);
try {
if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required.
session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "connecting", new Object[] { login }, this);
}
setLogin(login);
this.setDatasourcePlatform((DatasourcePlatform)session.getDatasourceLogin().getDatasourcePlatform());
try {
connect(login);
setIsInTransaction(false);
} catch (RuntimeException exception) {
session.handleSevere(exception);
}
session.getEventManager().postConnect(this);
incrementCallCount(session);
try {
buildConnectLog(session);
} finally {
decrementCallCount();
}
} finally {
session.endOperationProfile(SessionProfiler.CONNECT);
}
|
public synchronized void | decrementCallCount()Used for load balancing and external pooling.
setCallCount(getCallCount() - 1);
if (usesExternalConnectionPooling() && (!isInTransaction()) && (getCallCount() == 0)) {
try {
closeConnection();
} catch (DatabaseException ignore) {
}
// Don't allow for errors to be masked by disconnect.
}
|
public void | disconnect(oracle.toplink.essentials.internal.sessions.AbstractSession session)Disconnect from the datasource.
session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "disconnect", (Object[])null, this);
if (getDatasourceConnection() == null) {
return;
}
session.incrementProfile(SessionProfiler.TlDisconnects);
session.startOperationProfile(SessionProfiler.CONNECT);
closeDatasourceConnection();
setDatasourceConnection(null);
setIsInTransaction(false);
session.endOperationProfile(SessionProfiler.CONNECT);
|
public java.lang.Object | executeCall(oracle.toplink.essentials.queryframework.Call call, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractSession session)Execute the call.
// If the login is null, then this accessor has never been connected.
if (getLogin() == null) {
throw DatabaseException.databaseAccessorNotConnected();
}
if (session.shouldLog(SessionLog.FINE, SessionLog.SQL)) {// pre-check to improve performance
session.log(SessionLog.FINE, SessionLog.SQL, call.getLogString(this), (Object[])null, this, false);
}
Object result = basicExecuteCall(call, translationRow, session);
return result;
|
public void | flushSelectCalls(oracle.toplink.essentials.internal.sessions.AbstractSession session)Added as a result of Bug 2804663 - satisfy the Accessor interface
implementation.
// By default do nothing.
|
public int | getCallCount()Used for load balancing and external pooling.
return callCount;
|
public java.util.Vector | getColumnInfo(java.lang.String catalog, java.lang.String schema, java.lang.String tableName, java.lang.String columnName, oracle.toplink.essentials.internal.sessions.AbstractSession session)Return column information for the specified
database objects.
return new Vector();
|
public java.sql.Connection | getConnection()Helper method to return the JDBC connection for DatabaseAccessor.
Was going to deprecate this, but since most clients are JDBC this is useful.
return (java.sql.Connection)getDatasourceConnection();
|
public java.lang.Object | getDatasourceConnection()Return the driver level connection.
return datasourceConnection;
|
public oracle.toplink.essentials.internal.databaseaccess.DatasourcePlatform | getDatasourcePlatform()Return the platform.
return platform;
|
public oracle.toplink.essentials.sessions.Login | getLogin()Return the login
return login;
|
public java.util.Vector | getTableInfo(java.lang.String catalog, java.lang.String schema, java.lang.String tableName, java.lang.String[] types, oracle.toplink.essentials.internal.sessions.AbstractSession session)Return table information for the specified
database objects.
return new Vector();
|
public synchronized void | incrementCallCount(oracle.toplink.essentials.internal.sessions.AbstractSession session)Used for load balancing and external pooling.
setCallCount(getCallCount() + 1);
if (getCallCount() == 1) {
// If the login is null, then this accessor has never been connected.
if (getLogin() == null) {
throw DatabaseException.databaseAccessorNotConnected();
}
// If the connection is no longer connected, it may have timed out.
if (getDatasourceConnection() != null) {
if (!isConnected()) {
if (isInTransaction()) {
throw DatabaseException.databaseAccessorNotConnected();
} else {
reconnect(session);
}
}
} else {
// If ExternalConnectionPooling is used, the connection can be re-established.
if (usesExternalConnectionPooling()) {
reconnect(session);
} else {
throw DatabaseException.databaseAccessorNotConnected();
}
}
}
|
public boolean | isConnected()Return true if the accessor is currently connected to a data source.
Return false otherwise.
if ((getDatasourceConnection() == null) && (getLogin() == null)) {
return false;
}
if (usesExternalConnectionPooling()) {
return true;// As can always reconnect.
}
if (getDatasourceConnection() == null) {
return false;
}
return isDatasourceConnected();
|
protected abstract boolean | isDatasourceConnected()Return if the driver level connection is connected.
|
public boolean | isInTransaction()Return the transaction status of the receiver.
return isInTransaction;
|
protected void | reconnect(oracle.toplink.essentials.internal.sessions.AbstractSession session)Attempt to save some of the cost associated with getting a fresh connection.
Assume the DatabaseDriver has been cached, if appropriate.
Note: Connections that are participating in transactions will not be refreshd.^M
session.log(SessionLog.FINEST, SessionLog.CONNECTION, "reconnecting_to_external_connection_pool");
session.startOperationProfile(SessionProfiler.CONNECT);
connect(getLogin());
session.endOperationProfile(SessionProfiler.CONNECT);
|
public void | reestablishConnection(oracle.toplink.essentials.internal.sessions.AbstractSession session)PUBLIC:
Reconnect to the database. This can be used if the connection was disconnected or timedout.
This ensures that the security is checked as it is public.
Because the messages can take a long time to build,
pre-check whether messages should be logged.
if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required.
Object[] args = { getLogin() };
session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "reconnecting", args, this);
}
reconnect(session);
setIsInTransaction(false);
session.getEventManager().postConnect(this);
|
public void | rollbackTransaction(oracle.toplink.essentials.internal.sessions.AbstractSession session)Rollback the transaction on the datasource. If not using managed transaction rollback the local transaction.
if (usesExternalTransactionController()) {
// if there is no external TX controller, then that means we are currently not synchronized
// with a global JTS transaction. In this case, there won't be any 'afterCompletion'
// callbacks so we have to release the connection here. It is possible (WLS 5.1) to choose
// 'usesExternalTransactionController' on the login, but still acquire a uow that WON'T be
// synchronized with a global TX.
if (session.getExternalTransactionController() == null) {
setIsInTransaction(false);
if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) {
closeConnection();
setDatasourceConnection(null);
}
}
return;
}
session.log(SessionLog.FINER, SessionLog.TRANSACTION, "rollback_transaction", (Object[])null, this);
try {
session.startOperationProfile(SessionProfiler.TRANSACTION);
incrementCallCount(session);
basicRollbackTransaction(session);
} finally {
// false=="rolled back"; false=="not jts transactioin"
session.afterTransaction(false, false);
setIsInTransaction(false);
decrementCallCount();
session.endOperationProfile(SessionProfiler.TRANSACTION);
}
|
protected void | setCallCount(int callCount)Used for load balancing and external pooling.
this.callCount = callCount;
|
protected void | setDatasourceConnection(java.lang.Object connection)If client requires to manually set connection they can use the connection manager.
this.datasourceConnection = connection;
|
public void | setDatasourcePlatform(oracle.toplink.essentials.internal.databaseaccess.DatasourcePlatform platform)Set the platform.
This should be set to the session's platform, not the connections
which may not be configured correctly.
this.platform = platform;
|
protected void | setIsConnected(boolean isConnected)Set whether the accessor has a connection to the "data store".
this.isConnected = isConnected;
|
protected void | setIsInTransaction(boolean value)Set the transaction transaction status of the receiver.
isInTransaction = value;
|
protected void | setLogin(oracle.toplink.essentials.sessions.Login login)SECURE:
set the login
this.login = login;
|
public boolean | usesExternalConnectionPooling()Return true if some external connection pool is in use.
if (getLogin() == null) {
throw DatabaseException.databaseAccessorNotConnected();
}
return getLogin().shouldUseExternalConnectionPooling();
|
public boolean | usesExternalTransactionController()Return true if some external transaction service is controlling transactions.
if (getLogin() == null) {
throw DatabaseException.databaseAccessorNotConnected();
}
return getLogin().shouldUseExternalTransactionController();
|
public void | writesCompleted(oracle.toplink.essentials.internal.sessions.AbstractSession session)This method will be called after a series of writes have been issued to
mark where a particular set of writes has completed. It will be called
from commitTransaction and may be called from writeChanges. Its main
purpose is to ensure that the batched statements have been executed
//this is a no-op in this method as we do not batch on this accessor
|