Top Description Fields Constructors Methods
org.eclipse.persistence.internal.databaseaccess

public Class DatabaseAccessor

extends DatasourceAccessor
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .InputStream, .StringWriter, java.math.BigDecimal, java.sql.CallableStatement, .Connection, .DatabaseMetaData, .PreparedStatement, .ResultSet, .ResultSetMetaData, .SQLException, .SQLWarning, .Statement, .Types, java.util.Enumeration, .HashMap, .Hashtable, .List, .Map, .Vector, org.eclipse.persistence.exceptions.DatabaseException, .QueryException, org.eclipse.persistence.internal.helper.ClassConstants, .DatabaseField, .Helper, .LOBValueWriter, .NonSynchronizedVector, .ThreadCursoredList, org.eclipse.persistence.internal.localization.ExceptionLocalization, .ToStringLocalization, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .ArrayRecord, org.eclipse.persistence.logging.SessionLog, org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor, org.eclipse.persistence.queries.Call, .DatabaseQuery, org.eclipse.persistence.sessions.DatabaseLogin, .DatabaseRecord, .Login, .SessionProfiler

INTERNAL: DatabaseAccessor is private to EclipseLink. It encapsulates low level database operations (such as executing SQL and reading data by row). Database accessor defines a protocol by which EclipseLink may invoke these operations.

DatabaseAccessor also defines a single reference through which all configuration dependent behavior may be invoked.

DabaseAccessor implements the following behavior.

DatabaseAccessor dispatches the following protocols to its platform reference. DatabaseAccessor dispatches the following protocols to the schema object.
Since
TOPLink/Java 1.0
See Also
DatabasePlatform

Field Summary

Modifier and TypeField and Description
protected BatchWritingMechanism
activeBatchWritingMechanism

This attribute will be used to store the currently active Batch Mechanism

protected DynamicSQLBatchWritingMechanism
dynamicSQLMechanism

These two attributes store the available BatchWritingMechanisms.

protected Statement
dynamicStatement

PERF: Cache the statement object for dynamic SQL execution.

protected boolean
protected LOBValueWriter
protected DatabaseMetaData
metaData

Cache of the connection's java.sql.DatabaseMetaData

protected ParameterizedSQLBatchWritingMechanism
public static boolean
shouldUseDynamicStatements

PERF: Backdoor to disabling dynamic statements.

protected Map<String, Statement>
statementCache

Stores statement handles for common used prepared statements.

Inherited from org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor:
callCountcurrentSessioncustomizerdatasourceConnectionisConnectedisInTransactionisValidloginplatformpoolpossibleFailureREAD_STATEMENTS_COUNT_PROPERTYreadStatementsCountsequencingCallbackshouldCheckConnectionSTOREDPROCEDURE_STATEMENTS_COUNT_PROPERTYstoredProcedureStatementsCountusesExternalConnectionPoolingWRITE_STATEMENTS_COUNT_PROPERTYwriteStatementsCount

Constructor Summary

AccessConstructor and Description
public
public
DatabaseAccessor(Object connection)

Create a database accessor with the given connection.

Method Summary

Modifier and TypeMethod and Description
public synchronized Statement
allocateDynamicStatement(Connection connection)

Allocate a statement for dynamic SQL execution.

public void
public void
public Object

Returns:

depending of the type either the row count, row or vector of rows.
basicExecuteCall
(Call call, AbstractRecord translationRow, AbstractSession session)

Implements abstract org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.basicExecuteCall.

Execute the call.
public Object

Returns:

depending of the type either the row count, row or vector of rows.
basicExecuteCall
(Call call, AbstractRecord translationRow, AbstractSession session, boolean batch)

Execute the call.

public void
protected void
buildConnectLog(AbstractSession session)

Implements abstract org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.buildConnectLog.

If logging is turned on and the JDBC implementation supports meta data then display connection info.
public AbstractRecord
buildOutputRow(CallableStatement statement, DatabaseCall call, AbstractSession session)

Build a row from the output parameters of a sp call.

public Vector<DatabaseField>
buildSortedFields(Vector<DatabaseField> fields, ResultSet resultSet, AbstractSession session)

Return the field sorted in the correct order corresponding to the result set.

protected Vector<AbstractRecord>
buildThreadCursoredResult(final DatabaseCall dbCall, final ResultSet resultSet, final Statement statement, final ResultSetMetaData metaData, final AbstractSession session)

This allows for the rows to be fetched concurrently to the objects being built.

protected void
checkTransactionIsolation(AbstractSession session)

Check to see if the transaction isolation needs to be set for the newly created connection.

public void
clearStatementCache(AbstractSession session)

Flush the statement cache.

public Object
public void
public void
closeCursor(ResultSet resultSet, AbstractSession session)

Close the result set of the cursored stream.

public void
public void
closeStatement(Statement statement, AbstractSession session, DatabaseCall call)

INTERNAL: Closes a PreparedStatement (which is supposed to close it's current resultSet).

public void
protected void
public AbstractRecord
cursorRetrieveNextRow(Vector<DatabaseField> fields, ResultSet resultSet, AbstractSession session)

Advance the result set and return a Record populated with values from the next valid row in the result set.

public AbstractRecord
cursorRetrievePreviousRow(Vector<DatabaseField> fields, ResultSet resultSet, AbstractSession session)

Advance the result set and return a DatabaseRow populated with values from the next valid row in the result set.

public void
public boolean
execute(DatabaseCall call, Statement statement, AbstractSession session)

Execute the statement.

protected void
executeBatchedStatement(PreparedStatement statement, AbstractSession session)

Execute the EclipseLink dynamically batched/concatenated statement.

public Object

Returns:

depending of the type either the row count, row or vector of rows.
executeCall
(Call call, AbstractRecord translationRow, AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.executeCall.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.executeCall.

Execute the call.
public Object
executeDirectNoSelect(Statement statement, DatabaseCall call, AbstractSession session)

Execute the statement.

protected int
executeJDK12BatchStatement(Statement statement, DatabaseCall dbCall, AbstractSession session, boolean isStatementPrepared)

Execute the batched statement through the JDBC2 API.

protected Object
executeNoSelect(DatabaseCall call, Statement statement, AbstractSession session)

Execute the statement.

public ResultSet
executeSelect(DatabaseCall call, Statement statement, AbstractSession session)

Execute the statement.

protected AbstractRecord
fetchRow(Vector<DatabaseField> fields, ResultSet resultSet, ResultSetMetaData metaData, AbstractSession session)

Return a new DatabaseRow.

public AbstractRecord
fetchRow(Vector<DatabaseField> fields, DatabaseField[] fieldsArray, ResultSet resultSet, ResultSetMetaData metaData, AbstractSession session)

Return a new DatabaseRow.

public void
public BatchWritingMechanism
getActiveBatchWritingMechanism(AbstractSession session)

INTERNAL: This method is used internally to return the active batch writing mechanism to batch the statement

public String

Returns:

current calatog name
getCatalog
()

Get the current schema.

public Vector<AbstractRecord>

Returns:

a Vector of DatabaseRows.
getColumnInfo
(String
a catalog name; "" retrieves those without a catalog; null means drop catalog name from the selection criteria
catalog
,
String
schema name pattern; "" retrieves those without a schema
schema
,
String
a table name pattern
tableName
,
String
a column name pattern
columnName
,
AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.getColumnInfo.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.getColumnInfo.

Get a description of table columns available in a catalog.
public Vector<AbstractRecord>
getColumnInfo(String tableName, String columnName, AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.getColumnInfo.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.getColumnInfo.

Return the column metadata for the specified selection criteria limited to the context of the current Accessor.
protected Vector<DatabaseField>
getColumnNames(ResultSet resultSet, AbstractSession session)

Return the column names from a result sets meta data as a vector of DatabaseFields.

public Connection
public DatabaseMetaData
getConnectionMetaData()

return the cached metaData

protected DynamicSQLBatchWritingMechanism
getDynamicSQLMechanism()

Lazy init the dynamic SQL mechanism.

public LOBValueWriter
getLOBWriter()

Return the LOBValueWriter instance.

public Object
getObject(ResultSet resultSet, DatabaseField field, ResultSetMetaData metaData, int columnNumber, DatabasePlatform platform, boolean optimizeData, AbstractSession session)

Return an object retrieved from resultSet with the getObject() method.

protected Object

Returns:

new instance of converted type or this if no optimized conversion wasdone
getObjectThroughOptimizedDataConversion
(ResultSet
JDBC ResultSet with query result
resultSet
,
DatabaseField
database field mapping
field
,
int
database type from java.sql.Types or provider specific type
type
,
int
number of column to fetch
columnNumber
,
DatabasePlatform
current database platform
platform
,
AbstractSession
current database session
session
)

Handle the ResultSet conversion into java optimally through calling the direct type API.

protected ParameterizedSQLBatchWritingMechanism
getParameterizedMechanism()

Lazy init the parameterized SQL mechanism.

public DatabasePlatform
getPlatform()

Return the platform.

public String

Returns:

current schema name
getSchema
()

Get the current schema.

protected synchronized Map<String, Statement>
getStatementCache()

The statement cache stores a fixed sized number of prepared statements.

public Vector<AbstractRecord>

Returns:

a Vector of DatabaseRows.
getTableInfo
(String
a catalog name; "" retrieves those without a catalog; null means drop catalog name from the selection criteria
catalog
,
String
a schema name pattern; "" retrieves those without a schema
schema
,
String
a table name pattern
tableName
,
String[]
a list of table types to include; null returns all types
types
,
AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.getTableInfo.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.getTableInfo.

Get a description of tables available in a catalog.
public Vector<AbstractRecord>
getTableInfo(String tableName, String[] types, AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.getTableInfo.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.getTableInfo.

Return the table metadata for the specified selection criteria limited to the context of the current Accessor.
protected boolean
hasStatementCache()

Return if the accessor has any cached statements.

private boolean
isArray(int type)

Return if the JDBC type is a ARRAY type.

public static boolean
isBlob(int type)

Return if the JDBC type is a binary type such as blob.

public static boolean
isClob(int type)

Return if the JDBC type is a large character type such as clob.

public boolean
isDatasourceConnected()

Implements abstract org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.isDatasourceConnected.

Return true if the receiver is currently connected to a data source.
public boolean
isDynamicStatementInUse()

Return the cached statement for dynamic SQL execution is in use.

protected boolean
isInBatchWritingMode(AbstractSession session)

Return the batch writing mode.

private boolean
isStruct(int type, Object value)

Return if the JDBC type is a STRUCT type.

public void
populateRow(DatabaseField[] fieldsArray, Object[] values, ResultSet resultSet, ResultSetMetaData metaData, AbstractSession session, int startIndex, int endIndex)

public Statement
prepareStatement(DatabaseCall call, AbstractSession session)

Prepare the SQL statement for the call.

public Statement
prepareStatement(DatabaseCall call, AbstractSession session, boolean
boolean flag set to true to unwrap the connection before preparing the statement in the case of a parameterized call.
unwrapConnection
)

Prepare the SQL statement for the call.

public PreparedStatement
prepareStatement(String sql, AbstractSession session, boolean callable)

Prepare the SQL statement for the call.

public DatabaseException
processExceptionForCommError(AbstractSession session, SQLException exception, Call call)

This method is used to process an SQL exception and determine if the exception should be passed on for further processing.

public Object
processResultSet(ResultSet resultSet, DatabaseCall call, Statement statement, AbstractSession session)

Fetch all the rows from the result set.

protected void
reconnect(AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.reconnect.

Attempt to save some of the cost associated with getting a fresh connection.
public void
releaseStatement(Statement statement, String sqlString, DatabaseCall call, AbstractSession session)

Release the statement through closing it or putting it back in the statement cache.

protected void
resetStatementFromCall(Statement statement, DatabaseCall call)

Reset the Query Timeout, Max Rows, Resultset fetch size on the Statement if the DatabaseCall has values which differ from the default settings.

public void
public void
setActiveBatchWritingMechanism(BatchWritingMechanism mechanism)

INTERNAL: This method is used to set the active Batch Mechanism on the accessor.

public void
setActiveBatchWritingMechanismToDynamicSQL()

INTERNAL: This method is used to set the active Batch Mechanism on the accessor.

public void
setActiveBatchWritingMechanismToParameterizedSQL()

INTERNAL: This method is used to set the active Batch Mechanism on the accessor.

public void
public synchronized void
setIsDynamicStatementInUse(boolean isDynamicStatementInUse)

Set if the cached statement for dynamic SQL execution is in use.

protected void
setStatementCache(Hashtable<String, Statement> statementCache)

The statement cache stores a fixed sized number of prepared statements.

protected Vector<DatabaseField>
sortFields(Vector<DatabaseField> fields, Vector<DatabaseField> columnNames)

This method will sort the fields in correct order based on the column names.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
writesCompleted(AbstractSession session)

Overrides org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.writesCompleted.

Implements org.eclipse.persistence.internal.databaseaccess.Accessor.writesCompleted.

This method will be called after a series of writes have been issued to mark where a particular set of writes has completed.
Inherited from org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor:
beginTransactioncloseJTSConnectionconnectcreateCustomizerdecrementCallCountgetCallCountgetDatasourceConnectiongetDatasourcePlatformgetLogingetPoolgetReadStatementsCountgetSequencingCallbackgetStoredProcedureStatementsCountgetWriteStatementsCountincrementCallCountisConnectedisInTransactionisPossibleFailureisValidreestablishConnectionreestablishCustomizerreleaseCustomizerreleaseCustomizerresetsetCallCountsetCustomizersetDatasourceConnectionsetIsConnectedsetIsInTransactionsetIsValidsetLoginsetPoolsetPossibleFailureusesExternalConnectionPoolingusesExternalTransactionController