<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Application Server Containers for J2EE Support for JavaServer Pages API Reference 10g (9.0.4) B10387-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.jsp.dbutil
Class ConnBean

    java.lang.Object
      |
      +--oracle.jsp.dbutil.ConnBean

All Implemented Interfaces:
  java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, JspScopeListener, java.io.Serializable

public class ConnBean
extends java.lang.Object
implements JspScopeListener, javax.servlet.http.HttpSessionBindingListener, 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 :

- User - user name for connection
- Password password for connection
- URL URL for database connection
- StmtCacheSize Enable and set the statement cache size
- ExecuteBatch Execute Batch Size for DMLs
- PreFetch Row prefetch size for the rows returned for queries.

See Also:
  Serialized Form

Field Summary
`protected static int` | `DEFAULT_BATCH_SIZE`
`protected static int` | `DEFAULT_PREFETCH_SIZE`
`protected int` | `m_batchSize`
`protected boolean` | `m_commitOnClose`
`protected java.sql.Connection` | `m_conn`
`protected javax.naming.InitialContext` | `m_context`
`protected javax.sql.DataSource` | `m_datasource`
`protected java.lang.String` | `m_location`
`protected java.lang.String` | `m_password`
`protected int` | `m_preFetch`
`protected boolean` | `m_registered`
`protected boolean` | `m_resetAutoCommit`
`protected int` | `m_scSize`
`protected java.lang.String` | `m_url`
`protected java.lang.String` | `m_user`

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.
`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(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(javax.servlet.http.HttpSessionBindingEvent event)`
`void` | `valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)`

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

Field Detail

### m_conn

    protected transient java.sql.Connection m_conn

### m_user

    protected java.lang.String m_user

### m_password

    protected java.lang.String m_password

### m_url

    protected java.lang.String m_url

### m_scSize

    protected int m_scSize

### m_location

    protected java.lang.String m_location

### m_datasource

    protected javax.sql.DataSource m_datasource

### m_context

    protected transient javax.naming.InitialContext m_context

### m_commitOnClose

    protected boolean m_commitOnClose

### m_resetAutoCommit

    protected boolean m_resetAutoCommit

### m_registered

    protected boolean m_registered

### DEFAULT_PREFETCH_SIZE

    protected static int DEFAULT_PREFETCH_SIZE

### DEFAULT_BATCH_SIZE

    protected static int DEFAULT_BATCH_SIZE

### m_preFetch

    protected int m_preFetch

### m_batchSize

    protected int m_batchSize

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.
  Parameters:
    `location` - string name of the datasource location.

### getDataSource

    public java.lang.String getDataSource()

  Get the datasource location from which connections will be obtained.

### setUser

    public void setUser(java.lang.String user)

  Set the user name with which connections have to be obtained.
  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.
  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.
  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 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
    `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.
  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.
  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

    `java.lang.IllegalArgumentException`

### getCommitOnClose

    public java.lang.String getCommitOnClose()

### isConnectionClosed

    public boolean isConnectionClosed()

### outOfScope

    public void outOfScope(JspScopeEvent ae)

  Description copied from interface: `JspScopeListener`
  Invoked when a JSP scope that this object is attached to is ending.
  Specified by:
    `outOfScope` in interface `JspScopeListener`

### setConnection

    public void setConnection(java.sql.Connection conn)

### valueBound

    public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)

  Specified by:
    `valueBound` in interface `javax.servlet.http.HttpSessionBindingListener`

### valueUnbound

    public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)

  Specified by:
    `valueUnbound` in interface `javax.servlet.http.HttpSessionBindingListener`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle Application Server Containers for J2EE Support for JavaServer Pages API Reference 10g (9.0.4) B10387-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © YYYY, Oracle. All Rights Reserved.