Previous Topic

Next Topic

Using c-treeACE SQL Java Classes

This section describes how you use included c-treeACE SQL Java classes to issue and process c-treeACE SQL statements in Java stored procedures. The c-treeACE SQL Java classes are found in the ctreeSQLSP.jar file located in the C:\FairCom\V9.1.0\win32\bin\ace\sql\classes directory of your c-treeACE installation.

To process c-treeACE SQL statements in a stored procedure, you need to know whether the SQL statement generates results (in other words, if the statement is a query) or not. SELECT statements, for example, generate results: they retrieve data from one or more database tables and return the results as rows in a table.

Whether a statement generates such an SQL result set dictates which c-treeACE SQL Java classes you use to issue it:

  • To issue c-treeACE SQL statements that do not generate results (such as INSERT, GRANT, or CREATE), use either the SQLIStatement class (for one-time execution) or the SQLPStatement class (for repeated execution).
  • To issue c-treeACE SQL statements that generate results (SELECT and, in some cases, CALL), use the SQLCursor class to retrieve rows from a database or another procedure’s result set.

In either case, if you want to return a result set to the application, use the DhSQLResultSet class to store rows of data in a procedure result set. You must use DhSQLResultSet() methods to transfer data from an SQL result set to the procedure result set for the calling application to process it. You can also use DhSQLResultSet() methods to store rows of data generated internally by the procedure.

In addition, c-treeACE SQL provides the DhSQLException class so procedures can process and generate Java exceptions through the standard Java try { }, catch { }, and throw { } constructs.