Skip navigation links

Oracle Containers for J2EE Support for JavaServer Pages Java API Reference
10g (10.1.3.1.0)

B28960-01


oracle.jsp.dbutil
Class ConnBean

java.lang.Object
  extended byoracle.jsp.dbutil.ConnBean

All Implemented Interfaces:
java.util.EventListener, oracle.jsp.webutil.tagutil.event.JspScopeListener, java.io.Serializable

public class ConnBean
extends java.lang.Object
implements oracle.jsp.webutil.tagutil.event.JspScopeListener, java.io.Serializable

A Bean to open a database connection. Can enable statement caching and set properties like Row Prefetch and Execute Update Batch Size. Mechanism to create all kinds of statements is also provided.

Bean Properties that can be set and retrieved : <p/>

See Also:
Serialized Form

Constructor Summary
ConnBean()
           

 

Method Summary
 void close()
          Close the database connection and any opened cursors.
 void connect()
          Establish a database connection with the user name, password and URL set before.
 java.lang.String getCommitOnClose()
           
 java.sql.Connection getConnection()
          Get the underlying connection object.
 oracle.jsp.dbutil.CursorBean getCursorBean(int stype, java.lang.String sql)
          Creates a cursor and returns a CursorBean.
 java.lang.String getDataSource()
          Get the datasource location from which connections will be obtained.
 int getExecuteBatch()
          Get the execute batch size for this connection bean.
 java.lang.String getPassword()
          Get the password for this connection bean.
 int getPreFetch()
          Get the Row prefetch size for this connection bean.
 int getStmtCacheSize()
          Get the statement cache size set for this connection bean.
 java.lang.String getURL()
          Get the URL for this connection bean.
 java.lang.String getUser()
          Get the user name for this connection bean.
 boolean isConnectionClosed()
           
 void outOfScope(oracle.jsp.webutil.tagutil.event.JspScopeEvent ae)
          Invoked when a JSP scope that this object is attached to is ending.
 void setCommitOnClose(java.lang.String commitOnClose)
           
 void setConnection(java.sql.Connection conn)
           
 void setDataSource(java.lang.String location)
          Set the datasource location from which connections will be obtained.
 void setExecuteBatch(int bsize)
          Set the Execute Batch Size for DMLs.
 void setPassword(java.lang.String password)
          Set the password with which connections have to be obtained.
 void setPreFetch(int prefSize)
          Set the Row prefetch size for the rows returned for queries.
 void setStmtCacheSize(int scsize)
          Enable and set the statement cache size.
 void setURL(java.lang.String url)
          Set the URL from which connections have to be obtained.
 void setUser(java.lang.String user)
          Set the user name with which connections have to be obtained.
 void valueBound(HttpSessionBindingEvent event)
           
 void valueUnbound(HttpSessionBindingEvent event)
           

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

ConnBean

public ConnBean()

Method Detail

setDataSource

public void setDataSource(java.lang.String location)
Set the datasource location from which connections will be obtained. <p/>
Parameters:
location - string name of the datasource location.

getDataSource

public java.lang.String getDataSource()
Get the datasource location from which connections will be obtained. <p/>

setUser

public void setUser(java.lang.String user)
Set the user name with which connections have to be obtained. <p/>
Parameters:
user - Username to be set.

getUser

public java.lang.String getUser()
Get the user name for this connection bean. Returns null if not set.
Returns:
user name for this connection bean.

setPassword

public void setPassword(java.lang.String password)
Set the password with which connections have to be obtained. <p/>
Parameters:
password - Passowrd to be set.

getPassword

public java.lang.String getPassword()
Get the password for this connection bean. Returns null if not set.
Returns:
password for this connection bean.

setURL

public void setURL(java.lang.String url)
Set the URL from which connections have to be obtained. <p/>
Parameters:
url - URL to be set.

getURL

public java.lang.String getURL()
Get the URL for this connection bean. Returns null if not set.
Returns:
URL for this connection bean.

connect

public void connect()
             throws java.sql.SQLException
Establish a database connection with the user name, password and URL set before.
Throws:
java.sql.SQLException - if a database-access error occurs.

close

public void close()
           throws java.sql.SQLException
Close the database connection and any opened cursors. Also, frees up all the resources consumed by this connection.
Throws:
java.sql.SQLException - if a database-access error occurs.

getConnection

public java.sql.Connection getConnection()
Get the underlying connection object.
Returns:
JDBC Connection Object

getCursorBean

public oracle.jsp.dbutil.CursorBean getCursorBean(int stype,
                                                  java.lang.String sql)
                                           throws java.sql.SQLException
Creates a cursor and returns a CursorBean. Sql is ignored if it's a Plain Statement.
Parameters:
stype - Statement Type. Possible values are
  • CursorBean.PLAIN_STMT : For Plain Statements
  • CursorBean.PREP_STMT : For Prepared Statement
  • CursorBean.CALL_STMT : For Callable Statements
<p/>
sql - Sql string to be executed
Returns:
CursorBean Object
Throws:
java.sql.SQLException - if cursor creation fails.

setPreFetch

public void setPreFetch(int prefSize)
Set the Row prefetch size for the rows returned for queries. <p/>
Parameters:
prefSize - prefetch size

getPreFetch

public int getPreFetch()
Get the Row prefetch size for this connection bean.

Returns 10 (default) if not set.

Returns:
Row prefetch size for this connection bean.

setExecuteBatch

public void setExecuteBatch(int bsize)
Set the Execute Batch Size for DMLs. <p/>
Parameters:
bsize - Execute Batch Size

getExecuteBatch

public int getExecuteBatch()
Get the execute batch size for this connection bean.

Returns 1 (default) if not set.

Returns:
execute batch size for this connection bean.

setStmtCacheSize

public void setStmtCacheSize(int scsize)
                      throws java.sql.SQLException
Enable and set the statement cache size. Set the size to 0 to diable statement caching. Cursor caching is based on LRU policy with max size <it> scsize </it>.
Parameters:
scsize - Statement Cache Size
Throws:
java.sql.SQLException - An error occurred while enabling caching.

getStmtCacheSize

public int getStmtCacheSize()
Get the statement cache size set for this connection bean. Returns 0 if not set. Zero is the default value
Returns:
statement cache size for this connection bean.

setCommitOnClose

public void setCommitOnClose(java.lang.String commitOnClose)
                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getCommitOnClose

public java.lang.String getCommitOnClose()

isConnectionClosed

public boolean isConnectionClosed()

outOfScope

public void outOfScope(oracle.jsp.webutil.tagutil.event.JspScopeEvent ae)
Description copied from interface: oracle.jsp.webutil.tagutil.event.JspScopeListener
Invoked when a JSP scope that this object is attached to is ending.
Specified by:
outOfScope in interface oracle.jsp.webutil.tagutil.event.JspScopeListener

setConnection

public void setConnection(java.sql.Connection conn)

valueBound

public void valueBound(HttpSessionBindingEvent event)

valueUnbound

public void valueUnbound(HttpSessionBindingEvent event)

Skip navigation links

Oracle Containers for J2EE Support for JavaServer Pages Java API Reference
10g (10.1.3.1.0)

B28960-01


Copyright © 2004, 2006, Oracle. All rights reserved.