Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.jsp.dbutil
Class ConnBean

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

public class ConnBean
extends java.lang.Object
implements JspScopeListener

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.

  Field Summary
  `protected java.sql.Connection` | `m_conn`

  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.sql.Connection` | `getConnection()` Get the underlying connection object.
  `CursorBean` | `getCursorBean(int stype, java.lang.String sql)` Creates a cursor and returns a CursorBean.
  `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.
  `void` | `outOfScope(JspScopeEvent ae)` Invoked when a JSP scope that this object is attached to is ending.
  `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.

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

  Field Detail

  ### m_conn

      protected java.sql.Connection m_conn

  Constructor Detail

  ### ConnBean

      public ConnBean()

  Method Detail

  ### 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 scsize .

    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.

  ### 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

  Class | Tree | Deprecated | Index | Help

  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD