org.apache.derby.impl.drda
Class Database

java.lang.Object
  extended by org.apache.derby.impl.drda.Database
Direct Known Subclasses:
XADatabase

 class Database
extends java.lang.Object

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


Field Summary
protected  int accessCount
           
(package private)  java.lang.String attrString
           
protected  int byteOrder
           
protected  int ccsidDBC
           
protected  java.lang.String ccsidDBCEncoding
           
protected  int ccsidMBC
           
protected  java.lang.String ccsidMBCEncoding
           
protected  int ccsidSBC
           
protected  java.lang.String ccsidSBCEncoding
           
private  EngineConnection conn
          Connection to the database in the embedded engine.
protected  byte[] crrtkn
           
private  DRDAStatement currentStatement
           
protected  java.lang.String dbName
           
protected  java.lang.String decryptedPassword
           
protected  java.lang.String decryptedUserId
           
(package private)  DRDAStatement defaultStatement
           
private  boolean locatorSupport
           
private  boolean locatorSupportChecked
           
protected  java.lang.String password
           
protected  byte[] passwordSubstitute
           
private  PiggyBackedSessionData pbsd_
          Piggy-backed session data.
protected  boolean rdbAllowUpdates
           
protected  boolean RDBUPDRM_sent
           
protected  byte[] secTokenIn
           
protected  byte[] secTokenOut
           
protected  int securityMechanism
           
protected  boolean sendTRGDFTRT
           
protected  java.lang.String shortDbName
           
private  java.util.Hashtable stmtTable
           
protected  java.lang.String typDefNam
           
protected  java.lang.String userId
           
 
Constructor Summary
Database(java.lang.String dbName)
          Database constructor
 
Method Summary
(package private)  java.lang.String appendAttrString(java.util.Properties p)
           
protected  java.lang.String buildRuntimeInfo(java.lang.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 commit()
           
(package private)  EngineConnection getConnection()
          Get the connection
protected  DRDAStatement getCurrentStatement()
          Get current DRDA statement
protected  DRDAStatement getDefaultStatement()
          Get default statement for use in EXCIMM
protected  DRDAStatement getDefaultStatement(Pkgnamcsn pkgnamcsn)
          Get default statement for use in EXCIMM with specified pkgnamcsn The pkgnamcsn has the encoded isolation level
protected  DRDAStatement getDRDAStatement(Pkgnamcsn pkgnamcsn)
          Get DRDA statement based on pkgnamcsn
 PiggyBackedSessionData getPiggyBackedSessionData(boolean createOnDemand)
          Get a reference (handle) to the PiggyBackedSessionData object.
(package private)  int getPrepareIsolation()
           
private  void initializeDefaultStatement()
           
(package private)  void makeConnection(java.util.Properties p)
          Make a new connection using the database name and set the connection in the database
(package private)  void makeDummyConnection()
          This makes a dummy connection to the database in order to boot and/or create this last one.
protected  DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn)
          Get a new DRDA statement and store it in the stmtTable if stortStmt is true.
protected  void removeStatement(DRDAStatement stmt)
           
 void reset()
          This method resets the state of this Database object so that it can be re-used.
protected  void rollback()
           
(package private)  void setConnection(EngineConnection conn)
          Set connection and create the SQL statement for the default statement
protected  void setCurrentStatement(DRDAStatement stmt)
          Make statement the current statement
 void setDatabaseName(java.lang.String dbName)
          Take database name including attributes and set attrString and shortDbName accordingly.
(package private)  void setDrdaID(java.lang.String drdaID)
           
(package private)  void setPrepareIsolation(int level)
          Set the internal isolation level to use for preparing statements.
protected  void storeStatement(DRDAStatement stmt)
          Store DRDA prepared statement
(package private)  boolean supportsLocator()
          Checks whether database can support locators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbName

protected java.lang.String dbName

shortDbName

protected java.lang.String shortDbName

attrString

java.lang.String attrString

securityMechanism

protected int securityMechanism

userId

protected java.lang.String userId

password

protected java.lang.String password

decryptedUserId

protected java.lang.String decryptedUserId

decryptedPassword

protected java.lang.String decryptedPassword

passwordSubstitute

protected byte[] passwordSubstitute

rdbAllowUpdates

protected boolean rdbAllowUpdates

accessCount

protected int accessCount

secTokenIn

protected byte[] secTokenIn

secTokenOut

protected byte[] secTokenOut

crrtkn

protected byte[] crrtkn

typDefNam

protected java.lang.String typDefNam

byteOrder

protected int byteOrder

ccsidSBC

protected int ccsidSBC

ccsidDBC

protected int ccsidDBC

ccsidMBC

protected int ccsidMBC

ccsidSBCEncoding

protected java.lang.String ccsidSBCEncoding

ccsidDBCEncoding

protected java.lang.String ccsidDBCEncoding

ccsidMBCEncoding

protected java.lang.String ccsidMBCEncoding

RDBUPDRM_sent

protected boolean RDBUPDRM_sent

sendTRGDFTRT

protected boolean sendTRGDFTRT

conn

private EngineConnection conn
Connection to the database in the embedded engine.


defaultStatement

DRDAStatement defaultStatement

currentStatement

private DRDAStatement currentStatement

stmtTable

private java.util.Hashtable stmtTable

locatorSupport

private boolean locatorSupport

locatorSupportChecked

private boolean locatorSupportChecked

pbsd_

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.

Constructor Detail

Database

Database(java.lang.String dbName)
Database constructor

Parameters:
dbName - database name
Method Detail

setDatabaseName

public void setDatabaseName(java.lang.String dbName)
Take database name including attributes and set attrString and shortDbName accordingly.

Parameters:
dbName - database name, including attributes.

initializeDefaultStatement

private void initializeDefaultStatement()

setConnection

final void setConnection(EngineConnection conn)
                  throws java.sql.SQLException
Set connection and create the SQL statement for the default statement

Parameters:
conn - Connection
Throws:
java.sql.SQLException

getConnection

final EngineConnection getConnection()
Get the connection

Returns:
connection

getCurrentStatement

protected DRDAStatement getCurrentStatement()
Get current DRDA statement

Returns:
DRDAStatement
Throws:
java.sql.SQLException

getDefaultStatement

protected DRDAStatement getDefaultStatement()
Get default statement for use in EXCIMM

Returns:
DRDAStatement

getDefaultStatement

protected DRDAStatement getDefaultStatement(Pkgnamcsn pkgnamcsn)
Get default statement for use in EXCIMM with specified pkgnamcsn The pkgnamcsn has the encoded isolation level

Parameters:
pkgnamcsn - package/ section # for statement
Returns:
DRDAStatement

newDRDAStatement

protected DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn)
                                  throws java.sql.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 - Package name and section
Returns:
DRDAStatement
Throws:
java.sql.SQLException

getDRDAStatement

protected DRDAStatement getDRDAStatement(Pkgnamcsn pkgnamcsn)
Get DRDA statement based on pkgnamcsn

Parameters:
pkgnamcsn - - key to access statement
Returns:
DRDAStatement

makeConnection

void makeConnection(java.util.Properties p)
              throws java.sql.SQLException
Make a new connection using the database name and set the connection in the database

Parameters:
p - Properties for connection attributes to pass to connect
Throws:
java.sql.SQLException

makeDummyConnection

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.


appendAttrString

java.lang.String appendAttrString(java.util.Properties p)

storeStatement

protected void storeStatement(DRDAStatement stmt)
                       throws java.sql.SQLException
Store DRDA prepared statement

Parameters:
stmt - DRDA prepared statement
Throws:
java.sql.SQLException

removeStatement

protected void removeStatement(DRDAStatement stmt)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

setCurrentStatement

protected void setCurrentStatement(DRDAStatement stmt)
Make statement the current statement

Parameters:
stmt -

commit

protected void commit()
               throws java.sql.SQLException
Throws:
java.sql.SQLException

rollback

protected void rollback()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

close

protected void close()
              throws java.sql.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

Throws:
java.sql.SQLException - on conn.close() error to be handled in DRDAConnThread.

setDrdaID

final void setDrdaID(java.lang.String drdaID)

setPrepareIsolation

final void setPrepareIsolation(int level)
                        throws java.sql.SQLException
Set the internal isolation level to use for preparing statements. Subsequent prepares will use this isoalation level

Parameters:
level - internal isolation level
Throws:
java.sql.SQLException
See Also:
EngineConnection.setPrepareIsolation(int)

getPrepareIsolation

final int getPrepareIsolation()
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

buildRuntimeInfo

protected java.lang.String buildRuntimeInfo(java.lang.String indent,
                                            LocalizedResource localLangUtil)

supportsLocator

boolean supportsLocator()
                  throws java.sql.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:
true if locators are supported, falseThrows:
java.sql.SQLException - if metadata call fails

reset

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.


getPiggyBackedSessionData

public PiggyBackedSessionData getPiggyBackedSessionData(boolean createOnDemand)
                                                 throws java.sql.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 - if true create the PiggyBackedSessionData on demand
Returns:
a reference to the PBSD object or null
Throws:
java.sql.SQLException

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.