If Most Dynamic Statements Are Executed Infrequently

Dynamic SQL statements are executed only once or twice in a session for an application.

  • Set the connection property DYNAMIC_PREPARE to false.

  • To return PreparedStatement objects containing uncompiled statements, use Connection.prepareStatement in the standard way:
    PreparedStatement ps_uncomp = 
       Connection.prepareStatement(sql_string);
  • To return PreparedStatement objects containing precompiled statements, use SybConnection.prepareStatement with dynamic set to true. For example:
    PreparedStatement ps_precomp = 
       (SybConnection)conn.prepareStatement(sql_string, true);