Comments in a JDBC application

To document your JDBC program, you need to include comments. You can use Java comments outside of JDBC methods and Java or SQL comments in SQL statement strings.

You can include Java comments outside JDBC methods, wherever the Java language permits them. Within an SQL statement string in a JDBC method call, you can use comments in the following places:
  • For connections to Db2® on Linux, UNIX, and Windows systems data servers or Informix® data servers, comments can be:
    • Anywhere in the SQL statement string, and enclosed in /* and */ pairs. /* and */ pairs can be nested.
    • At the end of the SQL statement string, and preceded by two hyphens (--).
  • For connections to Informix data servers only, comments can be enclosed in left curly bracket ({) and right curly bracket (}) pairs.
    Restriction: A comment that is enclosed in a { and } pair is not valid if either of the following conditions is true:
    • The SQL statement string is not a stored procedure call, the SQL statement string is preceded and followed by comments that are enclosed in { and } pairs, and the comment at the beginning of the SQL statement string begins with the word call.
    • The SQL statement string is a stored procedure call, and the comment {call} is at the beginning of the escape syntax for the stored procedure call.
    • The comment contains any of the following characters:
      • Single quotation mark (')
      • Double quotation mark (")
      • Left curly bracket ({)
      • Right curly bracket (})
      • /*
    • The comment can be interpreted as SQL escape syntax. Comments that begin with the following characters can be interpreted as SQL escape syntax:
      • d followed by a space
      • t followed by a space
      • ts followed by a space
      • escape followed by a space
      • oj followed by a space
      • fn followed by a space

    For example, the following SQL statement strings are not valid:

    "{call comment at beginning} select * from systables {ending comment}"
    "{{call} call mysp(?, ?)}"