Compare features of JDBC and SQLj. JDBC
What will be an ideal response?
JDBC is an API (Application Programming Interface) for database access in Java. Using
the JDBC 3.0 API, you can access virtually any data source, from relational databases to
spreadsheets to flat files. JDBC technology also provides a common base on which tools
and alternate interfaces can be built. The JDBC 3.0 API is comprised of two packages:
java.sql package and javax.sql package
The JDBC-ODBC Bridge allows applications written in the Java programming language
to use the JDBC API with many existing ODBC drivers. The Bridge is itself a driver
based on JDBC technology ("JDBC driver") that is defined in the class
sun.jdbc.odbc.JdbcOdbcDriver. The Bridge defines the JDBC sub protocol of
ODBC. In the next section two examples of JDBC applications are given, one with Sun’s
sun.jdbc.odbc.JdbcOdbcDriver and another with Oracle’s
oracle.jdbc.driver.OracleDriver. There are five steps in creating a JDBC application.
? Import JDBC classes or packages with JDBC classes
? Load JDBC drivers.
? Establish connection with the database.
? Execute SQL statements / interact with the database.
? Close connection.
SQLj
SQLj is an alternative to JDBC. SQLj is Oracle's implementation of the ANSI SQL-1999
Part-0 “Embedded SQL in Java”, which specifies the integration of SQL statements in Java programs. Oracle SQLj is more concise and thus easier to write than JDBC, and provides compile-time schema validation and syntax checking for easier debugging.
With SQLj, SQL statements can be embedded directly in a Java program. SQLj is an attractive alternative, because it can perform syntax checking of SQL statements at translation time. SQLj translator translates a Java program (.sqlj) with SQL statements into Java code (.java), which can be executed through the JDBC driver. SQLj code is more compact than its JDBC counterpart. Import classes. The java.sql package is imported for JDBC classes, sqlj.runtime and sqlj.runtime.ref packages are imported for SQLj runtime classes, oracle.sqlj.runtime package is imported for Oracle class. Connect to the database. Connection to Oracle database is achieved with Oracle.connect() method. The method takes four parameters, url, username, password and autocommit mode. The autocommit mode could be true or false. If false is used, then programmer has to commit SQL statements. If you are using any database other than Oracle, you would use DriverManager.registerDriver( ). It is not needed for Oracle database. Embed SQL statements. The SQL statements are embedded with #sql { sql_statement }; where #sql tells SQLj translator that the SQL statement follows. The statements may include host variables with : prefix (as seen in PL/SQL section), which are declared in Java program. For example, String variable dname is declared in Java and used as :dname in SQL statement as a host variable, and Java variable num is used as :num.
You might also like to view...
Which is the correct C++ condition to check whether the value of x is between 0 and 100 (inclusive) ?
a. 0 <= x <= 100 b. 0 < x < 100 c. 0 <= x && x <= 100 d. 0 <= x || x <= 100
You can use Web cloud services to work with others on the same files.
Answer the following statement true (T) or false (F)
Computer security is a set of established procedures, standards, policies, and tools that are used to protect a network from theft, misuse, and unwanted intrusions, activities, and attacks.
Answer the following statement true (T) or false (F)
All of the following statements are TRUE about the Text Import Wizard data EXCEPT:
A) Sometimes Excel will incorrectly identify the language used in the text file, and this may throw off the Text Import Wizard. B) The Text Import Wizard does have file size limitations, and occasionally you will get a text file that is too big to import into Excel. C) If you do not want to include all the headings or if there is a comment at the beginning of the file, you can tell Excel to start in any row below a target row so it will omit extraneous text. D) The Text Import Wizard that can be initiated by clicking the From Text button on the External Data tab.