Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.database
Class CachedPreparedStatement

    java.lang.Object
      org.jivesoftware.database.CachedPreparedStatement

    public class CachedPreparedStatement

extends Object

Allows PreparedStatement information to be cached. A prepared statement consists of a SQL statement containing bind variables as well as variable values. For example, the SQL statement `"SELECT * FROM person WHERE age > ?"` would have the integer variable `18` (which replaces the "?" chracter) to find all adults. This class encapsulates both the SQL string and bind variable values so that actual PreparedStatement can be created from that information later.

Author:
  Matt Tucker

Constructor Summary
`CachedPreparedStatement()` Constructs a new CachedPreparedStatement.
`CachedPreparedStatement(String sql)` Constructs a new CachedPreparedStatement.

Method Summary
`void` | `addBoolean(boolean value)` Adds a boolean parameter to the prepared statement.
`void` | `addInt(int value)` Adds an integer parameter to the prepared statement.
`void` | `addLong(long value)` Adds a long parameter to the prepared statement.
`void` | `addString(String value)` Adds a String parameter to the prepared statement.
`boolean` | `equals(Object object)`
`String` | `getSQL()` Returns the SQL.
`int` | `hashCode()`
`void` | `setParams(PreparedStatement pstmt)` Sets all parameters on the given PreparedStatement.
`void` | `setSQL(String sql)` Sets the SQL.
`String` | `toString()`

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

Constructor Detail

### CachedPreparedStatement

    public CachedPreparedStatement()

  Constructs a new CachedPreparedStatement.

### CachedPreparedStatement

    public CachedPreparedStatement(String sql)

  Constructs a new CachedPreparedStatement.

  Parameters:
    `sql` - the SQL.

Method Detail

### getSQL

    public String getSQL()

  Returns the SQL.

  Returns:
    the SQL.

### setSQL

    public void setSQL(String sql)

  Sets the SQL.

  Parameters:
    `sql` - the SQL.

### addBoolean

    public void addBoolean(boolean value)

  Adds a boolean parameter to the prepared statement.

  Parameters:
    `value` - the boolean value.

### addInt

    public void addInt(int value)

  Adds an integer parameter to the prepared statement.

  Parameters:
    `value` - the int value.

### addLong

    public void addLong(long value)

  Adds a long parameter to the prepared statement.

  Parameters:
    `value` - the long value.

### addString

    public void addString(String value)

  Adds a String parameter to the prepared statement.

  Parameters:
    `value` - the String value.

### setParams

    public void setParams(PreparedStatement pstmt)
                   throws SQLException

  Sets all parameters on the given PreparedStatement. The standard code block for turning a CachedPreparedStatement into a PreparedStatement is as follows:

       PreparedStatement pstmt = con.prepareStatement(cachedPstmt.getSQL());
       cachedPstmt.setParams(pstmt);

  Parameters:
    `pstmt` - the prepared statement.
  Throws:
    `SQLException` - if an SQL Exception occurs.

### equals

    public boolean equals(Object object)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Jive Software.