org.apache.derby.jdbc
Class EmbedPooledConnection

java.lang.Object
  extended byorg.apache.derby.jdbc.EmbedPooledConnection
All Implemented Interfaces:
BrokeredConnectionControl, javax.sql.PooledConnection
Direct Known Subclasses:
EmbedXAConnection

class EmbedPooledConnection
extends java.lang.Object
implements javax.sql.PooledConnection, BrokeredConnectionControl

A PooledConnection object is a connection object that provides hooks for connection pool management.

This is Cloudscape's implementation of a PooledConnection.


Field Summary
private  int connectionId
          The id for this connection.
protected  BrokeredConnection currentConnectionHandle
           
protected  ReferenceableDataSource dataSource
           
protected  int defaultIsolationLevel
           
private  boolean defaultReadOnly
           
private  java.util.Vector eventListener
           
private static int idCounter
          Static counter for connection ids
private  java.lang.String idString
          String representation of id
private  boolean isActive
           
private  java.lang.String password
           
protected  EmbedConnection realConnection
           
private  boolean requestPassword
          True if the password was passed in on the connection request, false if it came from the data source property.
private  java.lang.String username
           
 
Constructor Summary
(package private) EmbedPooledConnection(ReferenceableDataSource ds, java.lang.String u, java.lang.String p, boolean requestPassword)
           
 
Method Summary
 void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
          Add an event listener.
protected  void checkActive()
           
 void checkAutoCommit(boolean autoCommit)
          Allow control over setting auto commit mode.
 void checkCommit()
          Allow control over calling commit.
 void checkHoldCursors(int holdability)
          Are held cursors allowed.
 void checkRollback()
          Allow control over calling rollback.
 void checkSavepoint()
          Allow control over creating a Savepoint (JDBC 3.0)
 void close()
          Close the Pooled connection.
protected  void closeCurrentConnectionHandle()
          In this case the Listeners are *not* notified.
 boolean closingConnection()
          Close called on BrokeredConnection.
 java.sql.Connection getConnection()
          Create an object handle for a database connection.
protected  java.sql.Connection getNewCurrentConnectionHandle()
           
(package private)  java.lang.String getPassword()
           
 int getPrepareIsolation()
          Get prepare isolation level.
 java.sql.Connection getRealConnection()
          Return the real JDBC connection for the brokered connection.
(package private)  java.lang.String getUsername()
           
private  int nextId()
           
 void notifyClose()
           
 void notifyError(java.sql.SQLException exception)
           
 void notifyException(java.sql.SQLException sqle)
          Notify the control class that a SQLException was thrown during a call on one of the brokered connection's methods.
protected  void openRealConnection()
           
 void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
          Remove an event listener.
protected  void resetRealConnection()
           
 void setDrdaID(java.lang.String drdaID)
          set DrdaId for this connection.
 void setPrepareIsolation(int level)
          Set the internal isolation level to use for preparing statements.
 java.lang.String toString()
          Get the string representation of this pooled connection.
 java.sql.CallableStatement wrapStatement(java.sql.CallableStatement cs, java.lang.String sql)
          No need to wrap statements for PooledConnections.
 java.sql.PreparedStatement wrapStatement(java.sql.PreparedStatement ps, java.lang.String sql, java.lang.Object generatedKeys)
          No need to wrap statements for PooledConnections.
 java.sql.Statement wrapStatement(java.sql.Statement s)
          No need to wrap statements for PooledConnections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idCounter

private static int idCounter
Static counter for connection ids


connectionId

private int connectionId
The id for this connection.


idString

private java.lang.String idString
String representation of id


eventListener

private java.util.Vector eventListener

realConnection

protected EmbedConnection realConnection

defaultIsolationLevel

protected int defaultIsolationLevel

defaultReadOnly

private boolean defaultReadOnly

currentConnectionHandle

protected BrokeredConnection currentConnectionHandle

dataSource

protected final ReferenceableDataSource dataSource

username

private final java.lang.String username

password

private final java.lang.String password

requestPassword

private final boolean requestPassword
True if the password was passed in on the connection request, false if it came from the data source property.


isActive

private boolean isActive
Constructor Detail

EmbedPooledConnection

EmbedPooledConnection(ReferenceableDataSource ds,
                      java.lang.String u,
                      java.lang.String p,
                      boolean requestPassword)
                throws java.sql.SQLException
Method Detail

nextId

private int nextId()

getUsername

java.lang.String getUsername()

getPassword

java.lang.String getPassword()

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Create an object handle for a database connection.

Specified by:
getConnection in interface javax.sql.PooledConnection
Returns:
a Connection object
Throws:
java.sql.SQLException - - if a database-access error occurs.

openRealConnection

protected final void openRealConnection()
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getNewCurrentConnectionHandle

protected final java.sql.Connection getNewCurrentConnectionHandle()

closeCurrentConnectionHandle

protected void closeCurrentConnectionHandle()
                                     throws java.sql.SQLException
In this case the Listeners are *not* notified. JDBC 3.0 spec section 11.4

Throws:
java.sql.SQLException

resetRealConnection

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

close

public void close()
           throws java.sql.SQLException
Close the Pooled connection.

Specified by:
close in interface javax.sql.PooledConnection
Throws:
java.sql.SQLException - - if a database-access error occurs.

addConnectionEventListener

public final void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
Add an event listener.

Specified by:
addConnectionEventListener in interface javax.sql.PooledConnection

removeConnectionEventListener

public final void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
Remove an event listener.

Specified by:
removeConnectionEventListener in interface javax.sql.PooledConnection

getRealConnection

public java.sql.Connection getRealConnection()
                                      throws java.sql.SQLException
Description copied from interface: BrokeredConnectionControl
Return the real JDBC connection for the brokered connection.

Specified by:
getRealConnection in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

notifyError

public void notifyError(java.sql.SQLException exception)

notifyClose

public void notifyClose()

checkActive

protected final void checkActive()
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

notifyException

public void notifyException(java.sql.SQLException sqle)
Notify the control class that a SQLException was thrown during a call on one of the brokered connection's methods.

Specified by:
notifyException in interface BrokeredConnectionControl

checkAutoCommit

public void checkAutoCommit(boolean autoCommit)
                     throws java.sql.SQLException
Allow control over setting auto commit mode.

Specified by:
checkAutoCommit in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

checkHoldCursors

public void checkHoldCursors(int holdability)
                      throws java.sql.SQLException
Are held cursors allowed.

Specified by:
checkHoldCursors in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

checkSavepoint

public void checkSavepoint()
                    throws java.sql.SQLException
Allow control over creating a Savepoint (JDBC 3.0)

Specified by:
checkSavepoint in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

checkRollback

public void checkRollback()
                   throws java.sql.SQLException
Allow control over calling rollback.

Specified by:
checkRollback in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

checkCommit

public void checkCommit()
                 throws java.sql.SQLException
Allow control over calling commit.

Specified by:
checkCommit in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

closingConnection

public boolean closingConnection()
                          throws java.sql.SQLException
Close called on BrokeredConnection. If this call returns true then getRealConnection().close() will be called. Don't close the underlying real connection as it is pooled.

Specified by:
closingConnection in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

wrapStatement

public java.sql.Statement wrapStatement(java.sql.Statement s)
                                 throws java.sql.SQLException
No need to wrap statements for PooledConnections.

Specified by:
wrapStatement in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

wrapStatement

public java.sql.PreparedStatement wrapStatement(java.sql.PreparedStatement ps,
                                                java.lang.String sql,
                                                java.lang.Object generatedKeys)
                                         throws java.sql.SQLException
No need to wrap statements for PooledConnections.

Specified by:
wrapStatement in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

wrapStatement

public java.sql.CallableStatement wrapStatement(java.sql.CallableStatement cs,
                                                java.lang.String sql)
                                         throws java.sql.SQLException
No need to wrap statements for PooledConnections.

Specified by:
wrapStatement in interface BrokeredConnectionControl
Throws:
java.sql.SQLException

setDrdaID

public void setDrdaID(java.lang.String drdaID)
set DrdaId for this connection. Used by network server to identify connection.

Specified by:
setDrdaID in interface BrokeredConnectionControl
Parameters:
drdaID - drda connection identifier

setPrepareIsolation

public 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

Specified by:
setPrepareIsolation in interface BrokeredConnectionControl
Parameters:
level - internal isolation level
Throws:
java.sql.SQLException
See Also:
BrokeredConnection.setPrepareIsolation(int)

getPrepareIsolation

public int getPrepareIsolation()
                        throws java.sql.SQLException
Get prepare isolation level. For network server this will be the isolation level at which statements will be prepared.

Specified by:
getPrepareIsolation in interface BrokeredConnectionControl
Returns:
isolation level
Throws:
java.sql.SQLException

toString

public java.lang.String toString()
Get the string representation of this pooled connection. A pooled connection is assigned a separate id from a physical connection. When a container calls PooledConnection.toString(), it gets the string representation of this id. This is useful for developers implementing connection pools when they are trying to debug pooled connections.

Returns:
a string representation of the uniquie id for this pooled connection.

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.