Java and Relational Databases: SQLJ

Gray Clossman Phil Shaw Mark Hapner Oracle Corp. Sybase Inc. Corp. 400 Oracle Pkwy 6601 Bay Street 901 San Antonio Rd Redwood Shores, CA 94065 Emeryville, CA 94608 Palo Alto, CA 94303 [email protected] [email protected] [email protected]

Johannes Klein Richard Pledereder Brian Becker Tandem Computers Sybase Inc. Oracle Corp. 19333 Vallco Pkwy 6601 Bay Street 400 Oracle Pkwy Cupertino, CA 95014 Emeryville, CA 94608 Redwood Shores, CA 94065 johannes.klein@ tandem.com [email protected] bbecker@ us.oracle.com

1. ABSTRACT 4. Embedded SQL This Tutorial presents the latest developments in the area of SQLJ Embedded SQL allows Java programmers to include SQL Java and Relational Databases. The material is based on the clauses in their Java programs. The SQLJ Translator is then used SQL.J consortium effort whose goal is to leverage Java to perform design time validation of the SQL statements and technology for SQL processing. The SQLJ effort is driven by replace them with Java code. SQLJ Embedded SQL also specifies ma,jor industry vendors such as Oracle, Sybase, Tandem, a vendor neutral runtime infrastructure and a vendor neutral .JavaSoft, IBM, Informix and others. The SQLJ specifications representation of the preprocessed SQL statements. This allows describe Embedded SQL in Java, Java Stored Procedures, Java UDFs and Java Data Types. compiled applications to be portable across different database systems. Finally, some databases will install the preprocessed 1.1 Keywords SQL statements as statically optimized plans. SQL; Java; JDBC; SQLJ; ORDBMS; Java Relational. 5. Java Stored Procedures and Java UDFs 2. Overview SQLJ Stored Procedures and SQLJ User-Defined Functions allow The SQL,J specifications describe ways for Java to be used with the programmer to write these routines in Java and install them in SQL. SQLJ describes Java with Embedded SQL, Java Stored the form of JAR files into the database. SQL operations are PI-occdurcs and UDFs and Java Data Types; SQLJ is well expressed by either coding Embedded SQL or raw JDBC calls. intcgratcd with the JDBC API. The SQLJ approach to routines Client applications use JDBC, ODBC, etc. to invoke these and data types is sometimes referred to as Jcnja RelationaL procedures. By contrast, Java UDFs may be invoked from within 3. JDBC SQL DML statements. JDBC provides Java programmers with a Call Level 6. Java Data Types Interface to perform dynamic SQL operations. JDBC 1.0 is With SQLJ Data Types programmers may use Java Classes to now widely supported by database systems and tools. JDBC declare the types of columns, procedure parameters, etc. Java 2.0 is adding features that allows the application and the represents a very attractive choice for expressing complex types in database to exchange structured data, including Java a database, due to features like object-pass-by-value or the objects ot- SQL3 objects. sandbox execution model. SQL DML statements are extended to

Permiwdon to make digital or hard copiee of all or part of this work for permit the access to Java methods for relational operations such as personal or clssrroom use is granted without fee provided that project, filter, etc. copiee am not made or distributed for profit w commercial sdvsn- tag. and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to 7. REFERENCES redistribute to lists, raquirer prior #pacific permission and/or a fee. [I] SQLJ Specifications, Contact [email protected] SIGMOD ‘98 Seattle. WA, USA Q 1999 ACM 0-99791.996~6/99/006...56.00 or [email protected]. [2] JDBC Specification, http://java.sun.com/products/jdbc.

500