il.co.iter.dbdom
Class StoredProcedure

java.lang.Object
  |
  +--il.co.iter.dbdom.StoredProcedure

public class StoredProcedure
extends java.lang.Object

Represents a stored procedure with a known result set signature in the underlying databas. This class is not currently used. Some of the comments in the class are still highly relevant.

DBDOM makes extensive use of stored procedures. This class exists for two reasons:

  1. To hide the difference betbeen PreparedStatement and CallableStatement. The choice depends on whether or not support is available in a particular JDBC driver.
  2. To encapsulate common operations:
Statements (or their subclasses) that represent the stored procedures are kept as private members of DBDOMImplementation. They are not initialized in DBDOMImplementation's constructor, but rather on first access.

Keeping Statements in DBDOMImplementation optimizes for size, since individual DBNodes don't need to cary their own statements. This may become a performance bottleneck: only one Node at a time is able to execute a particular DOM method. If this in fact bocomes an issue, move StoredProcedure declarations to DBNode and it's subclasses.

Statements cannot be static members, because different instances of DBDOMImplementation may hold connections to different databases - with different Connection objects and possibly different versions of DBDOM and possibly different RDBMSs altogether.

All DBDOM stored procedures have a known type of result set. If a stored procedure returns a different type of result set than expected, it means that the database is incompatible with DBDOM or that there is a version missmatch between the database and the Java wrappers. See DBDOMSpException

StoredProcedure may be subclassed to emulate stored procedures in an RDMS that doesn't provide a native PS mechanism.


Field Summary
static int UNLIMITED
          Specifies that a stored procedure may return an unlimited number of results per invocation.
 
Constructor Summary
protected StoredProcedure(DBDOMImplementation dbDomImplementation, java.lang.String spName, int nOfParams, int nOfResults)
           
 
Method Summary
protected  java.sql.ResultSet executeQuery()
           
 java.lang.String getSpName()
          Returns the name of the SQL stored procedure
protected  void initStatementIfNull()
          This simple operation is implemented as a protected method to allow overriding by subclases.
protected  void setInt(int parameterIndex, int x)
           
protected  void setNull(int parameterIndex, int sqlType)
           
protected  void setNull(int paramIndex, int sqlType, java.lang.String typeName)
           
protected  void setString(int parameterIndex, java.lang.String x)
           
 java.lang.String toString()
          Returns the SQL string that would be used to run this SP against the databse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNLIMITED

public static final int UNLIMITED
Specifies that a stored procedure may return an unlimited number of results per invocation.
Constructor Detail

StoredProcedure

protected StoredProcedure(DBDOMImplementation dbDomImplementation,
                          java.lang.String spName,
                          int nOfParams,
                          int nOfResults)
Method Detail

initStatementIfNull

protected void initStatementIfNull()
                            throws java.sql.SQLException
This simple operation is implemented as a protected method to allow overriding by subclases.

In particular, a subclass that uses a CallableStatement as opposed to PreparedStatement should override this method.


executeQuery

protected java.sql.ResultSet executeQuery()

setInt

protected void setInt(int parameterIndex,
                      int x)

setString

protected void setString(int parameterIndex,
                         java.lang.String x)

setNull

protected void setNull(int parameterIndex,
                       int sqlType)

setNull

protected void setNull(int paramIndex,
                       int sqlType,
                       java.lang.String typeName)

toString

public java.lang.String toString()
Returns the SQL string that would be used to run this SP against the databse.
Overrides:
toString in class java.lang.Object

getSpName

public java.lang.String getSpName()
Returns the name of the SQL stored procedure