If Most Dynamic Statements Executed Are Multiple Times in a Session

Use the DYNAMIC_PREPARE and PreparedStatement objects to execute the dynamic statements multiple times in an application in the course of a session.

  • Set the connection property DYNAMIC_PREPARE to true.

  • To return PreparedStatement objects containing precompiled statements, use Connection.prepareStatement in the standard way:
    PreparedStatement ps_precomp = Connection.prepareStatement(sql_string);
  • To return PreparedStatement objects containing uncompiled statements, you can use either Connection.prepareCall or SybConnection.prepareStatement, with dynamic set to false. For example:
    PreparedStatement ps_uncomp =    (SybConnection)conn.prepareStatement(sql_string, false);
    PreparedStatement ps_uncomp = Connection.prepareCall(sql_string);
Related concepts
Prepared Statements in Portable Applications