From J Wiki
Jump to navigation Jump to search
JDD: Driver Locale | Handles | Data Sources | Data Driver | Error Messages | API: Connect Read Update Create Bulk Insert

Connection Handle

You start accessing a database by first opening a connection to the data source. The result is a number, called the connection handle. Subsequent requests to the data source use this connection handle.

Statement Handle

When you send a request to select some data, the result is also a number, called the statement handle. Again, subsequent requests that reference this selection use the statement handle. There may be more than one statement handle associated with a connection handle.

Closing Handles

In both cases, you should close the handle to free up resources when you are finished with it. For example, to read records from a file, you typically:

  • open a connection to the data source, returning a connection handle
  • make a selection on a specific file using the connection handle, returning a statement handle
  • read the records, using the statement handle
  • close the statement handle
  • close the connection handle

You must always close a connection handle explicitly. However, a statement handle may be closed if you have fetched all records selected - see the discussion of ddfet below. In any case, it is good practice to always close the statement handle explicitly, as there is no harm done if you try to close a handle that had already been closed.