Top Description Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv Class Database

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.drda.XADatabase
Imports
java.sql.ResultSet, .SQLException, java.util.Enumeration, .Hashtable, .Properties, org.apache.derby.iapi.jdbc.EngineConnection, org.apache.derby.shared.common.reference.Attribute, org.apache.derby.iapi.tools.i18n.LocalizedResource

Database stores information about the current database It is used so that a session may have more than one database

Field Summary

Modifier and TypeField and Description
protected int
pack-priv String
protected int
protected int
protected String
protected int
protected String
protected int
protected String
private EngineConnection
conn

Connection to the database in the embedded engine.

protected byte[]
private DRDAStatement
private String
protected String
protected String
pack-priv DRDAStatement
private boolean
private boolean
protected String
protected byte[]
private PiggyBackedSessionData
pbsd_

Piggy-backed session data.

protected boolean
protected boolean
protected byte[]
protected byte[]
protected int
protected boolean
private String
private Hashtable<Object, DRDAStatement>
stmtTable

Hash table for storing statements.

protected String
protected String

Constructor Summary

AccessConstructor and Description
pack-priv
Database(String
database name
dbName
)

Database constructor

Method Summary

Modifier and TypeMethod and Description
pack-priv String
protected String
buildRuntimeInfo(String indent, LocalizedResource localLangUtil)

protected void
close()

Database close does following cleanup tasks 1)Rollback any pending transaction on the Connection object (except for a global-XA Connection obejct) before closing the Connection.

protected void
pack-priv final EngineConnection

Returns:

connection
getConnection
()

Get the connection

protected DRDAStatement

Returns:

DRDAStatement
getCurrentStatement
()

Get current DRDA statement

public String
protected DRDAStatement

Returns:

DRDAStatement
getDefaultStatement
()

Get default statement for use in EXCIMM

protected DRDAStatement

Returns:

DRDAStatement
getDefaultStatement
(Pkgnamcsn
package/ section # for statement
pkgnamcsn
)

Get default statement for use in EXCIMM with specified pkgnamcsn The pkgnamcsn has the encoded isolation level

protected DRDAStatement

Returns:

DRDAStatement
getDRDAStatement
(Pkgnamcsn
- key to access statement
pkgnamcsn
)

Get DRDA statement based on pkgnamcsn

public PiggyBackedSessionData

Returns:

a reference to the PBSD object or null
getPiggyBackedSessionData
(boolean
if true create the PiggyBackedSessionData on demand
createOnDemand
)

Get a reference (handle) to the PiggyBackedSessionData object.

pack-priv final int
public String
private void
pack-priv void
makeConnection(Properties
Properties for connection attributes to pass to connect
p
)

Make a new connection using the database name and set the connection in the database

pack-priv void
makeDummyConnection()

This makes a dummy connection to the database in order to boot and/or create this last one.

protected DRDAStatement

Returns:

DRDAStatement
newDRDAStatement
(Pkgnamcsn
Package name and section
pkgnamcsn
)

Get a new DRDA statement and store it in the stmtTable if stortStmt is true.

protected void
public void
reset()

This method resets the state of this Database object so that it can be re-used.

protected void
pack-priv final void
setConnection(EngineConnection
Connection
conn
)

Set connection and create the SQL statement for the default statement

protected void
setCurrentStatement(DRDAStatement stmt)

Make statement the current statement

public void
setDatabaseName(String
database name, including attributes.
dbName
)

Take database name including attributes and set attrString and shortDbName accordingly.

pack-priv final void
setDrdaID(String drdaID)

pack-priv final void
setPrepareIsolation(int
internal isolation level
level
)

Set the internal isolation level to use for preparing statements.

protected void
storeStatement(DRDAStatement
DRDA prepared statement
stmt
)

Store DRDA prepared statement

pack-priv boolean

Returns:

true if locators are supported, false otherwise
supportsLocator
()

Checks whether database can support locators.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessCountback to summary
protected int accessCount
attrStringback to summary
pack-priv String attrString
byteOrderback to summary
protected int byteOrder
ccsidDBCback to summary
protected int ccsidDBC
ccsidDBCEncodingback to summary
protected String ccsidDBCEncoding
ccsidMBCback to summary
protected int ccsidMBC
ccsidMBCEncodingback to summary
protected String ccsidMBCEncoding
ccsidSBCback to summary
protected int ccsidSBC
ccsidSBCEncodingback to summary
protected String ccsidSBCEncoding
connback to summary
private EngineConnection conn

Connection to the database in the embedded engine.

crrtknback to summary
protected byte[] crrtkn
currentStatementback to summary
private DRDAStatement currentStatement
dbNameback to summary
private String dbName
decryptedPasswordback to summary
protected String decryptedPassword
decryptedUserIdback to summary
protected String decryptedUserId
defaultStatementback to summary
pack-priv DRDAStatement defaultStatement
locatorSupportback to summary
private boolean locatorSupport
locatorSupportCheckedback to summary
private boolean locatorSupportChecked
passwordback to summary
protected String password
passwordSubstituteback to summary
protected byte[] passwordSubstitute
pbsd_back to summary
private PiggyBackedSessionData pbsd_

Piggy-backed session data. Null if no piggy-backing has happened yet. Lazy initialization is acceptable since the client's cache initially is empty so that any request made prior to the first round of piggy-backing will trigger an actual request to the server.

rdbAllowUpdatesback to summary
protected boolean rdbAllowUpdates
RDBUPDRM_sentback to summary
protected boolean RDBUPDRM_sent
secTokenInback to summary
protected byte[] secTokenIn
secTokenOutback to summary
protected byte[] secTokenOut
securityMechanismback to summary
protected int securityMechanism
sendTRGDFTRTback to summary
protected boolean sendTRGDFTRT
shortDbNameback to summary
private String shortDbName
stmtTableback to summary
private Hashtable<Object, DRDAStatement> stmtTable

Hash table for storing statements.

typDefNamback to summary
protected String typDefNam
userIdback to summary
protected String userId

Constructor Detail

Databaseback to summary
pack-priv Database(String dbName)

Database constructor

Parameters
dbName:String

database name

Method Detail

appendAttrStringback to summary
pack-priv String appendAttrString(Properties p)
buildRuntimeInfoback to summary
protected String buildRuntimeInfo(String indent, LocalizedResource localLangUtil)
closeback to summary
protected void close() throws SQLException

Database close does following cleanup tasks 1)Rollback any pending transaction on the Connection object (except for a global-XA Connection obejct) before closing the Connection. Without the rollback, the Connection close will result into an exception if there is a pending transaction on that Connection. 2)Clean up the statement table

Exceptions
SQLException:
on conn.close() error to be handled in DRDAConnThread.
commitback to summary
protected void commit() throws SQLException
getConnectionback to summary
pack-priv final EngineConnection getConnection()

Get the connection

Returns:EngineConnection

connection

getCurrentStatementback to summary
protected DRDAStatement getCurrentStatement()

Get current DRDA statement

Returns:DRDAStatement

DRDAStatement

getDatabaseNameback to summary
public String getDatabaseName()
getDefaultStatementback to summary
protected DRDAStatement getDefaultStatement()

Get default statement for use in EXCIMM

Returns:DRDAStatement

DRDAStatement

getDefaultStatementback to summary
protected DRDAStatement getDefaultStatement(Pkgnamcsn pkgnamcsn)

Get default statement for use in EXCIMM with specified pkgnamcsn The pkgnamcsn has the encoded isolation level

Parameters
pkgnamcsn:Pkgnamcsn

package/ section # for statement

Returns:DRDAStatement

DRDAStatement

getDRDAStatementback to summary
protected DRDAStatement getDRDAStatement(Pkgnamcsn pkgnamcsn)

Get DRDA statement based on pkgnamcsn

Parameters
pkgnamcsn:Pkgnamcsn

- key to access statement

Returns:DRDAStatement

DRDAStatement

getPiggyBackedSessionDataback to summary
public PiggyBackedSessionData getPiggyBackedSessionData(boolean createOnDemand) throws SQLException

Get a reference (handle) to the PiggyBackedSessionData object. Null will be returned either if Database.conn is not a valid connection, or if the create argument is false and no object has yet been created.

Parameters
createOnDemand:boolean

if true create the PiggyBackedSessionData on demand

Returns:PiggyBackedSessionData

a reference to the PBSD object or null

getPrepareIsolationback to summary
pack-priv final int getPrepareIsolation() throws SQLException
getShortDbNameback to summary
public String getShortDbName()
initializeDefaultStatementback to summary
private void initializeDefaultStatement()
makeConnectionback to summary
pack-priv void makeConnection(Properties p) throws SQLException

Make a new connection using the database name and set the connection in the database

Parameters
p:Properties

Properties for connection attributes to pass to connect

makeDummyConnectionback to summary
pack-priv void makeDummyConnection()

This makes a dummy connection to the database in order to boot and/or create this last one. If database cannot be found or authentication does not succeed, this will throw a SQLException which we catch and do nothing. We don't pass a userid and password here as we don't need to for the purpose of this method - main goal is to cause the database to be booted via a dummy connection.

newDRDAStatementback to summary
protected DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn) throws SQLException

Get a new DRDA statement and store it in the stmtTable if stortStmt is true. If possible recycle an existing statement. When the server gets a new statement with a previously used pkgnamcsn, it means that client-side statement associated with this pkgnamcsn has been closed. In this case, server can re-use the DRDAStatement by doing the following: 1) Retrieve the old DRDAStatement associated with this pkgnamcsn and close it. 2) Reset the DRDAStatement state for re-use.

Parameters
pkgnamcsn:Pkgnamcsn

Package name and section

Returns:DRDAStatement

DRDAStatement

removeStatementback to summary
protected void removeStatement(DRDAStatement stmt) throws SQLException
resetback to summary
public void reset()

This method resets the state of this Database object so that it can be re-used.

Note

currently this method resets the variables related to security mechanisms that have been investigated as needing a reset. TODO: Investigate what all variables in this class need to be reset when this database object is re-used on a connection pooling or transaction pooling. see DRDAConnThread.parseACCSEC (CodePoint.RDBNAM) where database object is re-used on a connection reset.

rollbackback to summary
protected void rollback() throws SQLException
setConnectionback to summary
pack-priv final void setConnection(EngineConnection conn) throws SQLException

Set connection and create the SQL statement for the default statement

Parameters
conn:EngineConnection

Connection

setCurrentStatementback to summary
protected void setCurrentStatement(DRDAStatement stmt)

Make statement the current statement

setDatabaseNameback to summary
public void setDatabaseName(String dbName)

Take database name including attributes and set attrString and shortDbName accordingly.

Parameters
dbName:String

database name, including attributes.

setDrdaIDback to summary
pack-priv final void setDrdaID(String drdaID)
setPrepareIsolationback to summary
pack-priv final void setPrepareIsolation(int level) throws SQLException

Set the internal isolation level to use for preparing statements. Subsequent prepares will use this isoalation level

Parameters
level:int

internal isolation level

See Also
EngineConnection#setPrepareIsolation
storeStatementback to summary
protected void storeStatement(DRDAStatement stmt) throws SQLException

Store DRDA prepared statement

Parameters
stmt:DRDAStatement

DRDA prepared statement

supportsLocatorback to summary
pack-priv boolean supportsLocator() throws SQLException

Checks whether database can support locators. This is done by checking whether one of the stored procedures needed for locators exists. (If the database has been soft-upgraded from an earlier version, the procedures will not exist).

Returns:boolean

true if locators are supported, false otherwise

Exceptions
SQLException:
if metadata call fails