About SQLJ versus JDBC
How does SQLJ compare to JDBC? Here are some of the advantages that SQLJ
offers over coding directly in JDBC:
-
SQLJ programs require fewer lines of code than JDBC programs. They are
shorter, and hence easier to debug.
-
SQLJ can perform syntactic and semantic checking on the code, using
database connections at compile time.
-
SQLJ provides strong type-checking of query results and other return
parameters, while JDBC values are passed to and from SQL without
having been checked at compile time.
-
SQLJ provides a simplified way of processing SQL statements. Instead
of having to write separate method calls to bind each input parameter
and retrieve each select list item, you can write one SQL statement
that uses Java host variables. SQLJ takes care of the binding
for you.
However, JDBC provides finer-grained control over the execution of SQL
statements and offers true dynamic SQL capability. If your application
requires dynamic capability (discovery of database or instance metadata
at runtime), then you should use JDBC.
Related topics
Embedding SQL in Java Programs
Embedding SQL in Java Programs with SQLJ
Embedding SQL in Java Programs with JDBC
About Oracle JDBC drivers
Copyright © 1997, 2004, Oracle.
All rights reserved.