Manage Memory in jConnect Applications

Use the Statement objects and subclasses, if you notice increased memory use in jConnect applications

  • In jConnect applications, explicitly close all Statement objects and subclasses (for example, PreparedStatement, CallableStatement) after their last use to prevent statements from accumulating in memory. Closing only the ResultSet is not sufficient.

    For example, this statement causes problems:
    ResultSet rs = _conn.prepareCall(_query).execute();
    ...
    rs.close();
    Instead, use:
    PreparedStatement ps = _conn.prepareCall(_query);
    ResultSet rs = ps.executeQuery();
    ...
    rs.close();
    ps.close();
  • Native support for scrollable or updatable scrollable cursors may not be available, depending on the version of Adaptive Server or SQL Anywhere database you are connecting to. To support scrollable or updatable scrollable cursors when not supported natively by the back-end server, jConnect caches the row data on demand, on the client, on each call to ResultSet.next. However, when the end of the result set is reached, the entire result set is stored in client memory. Because this may cause a performance degradation, Sybase recommends that you use TYPE_SCROLL_INSENSITIVE result sets only when the result set is reasonably small. jConnect determines if the Adaptive Server connection supports native scrollable cursor functionality and uses it instead of client-side caching. As a result, most applications can expect significant performance gain in accessing out-of-order rows and reduction in client-side memory requirements.