The SQLj initiative defines three ways to combine Java and SQL:

  • SQLj Part 0 defines a mechanism for embedding SQL calls within Java code. The SQL is converted into JDBC calls by using a preprocessor.

  • SQLj Part 1 inverts this, placing Java within SQL. It defines extensions to the SQL syntax to allow Java static methods to be called either as if they were SQL stored procedures or as user-defined functions within SQL statements.

  • SQLj Part 2 also places Java within SQL, but here providing a mechanism for Java classes to be used to define SQL types. This allows table columns to be defined as a type of a Java class; a Java object instance can thus be stored directly in the column.

The following sections look at each of these in turn.

SQLj Part 0 ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.