6.4. Loading SQLJ Programs into the Database

The loadjava command-line utility may be used to load Java class files into the database. The class files may be loaded individually, or packed into a JAR file using the jar command-line utility and loaded together. The syntax for the loadjava command-line utility is provided in Appendix B. This section uses only a few simple options of the loadjava command-line utility, but they should be enough for most of your needs. First, I describe how to load the class files individually, and then I show how to pack the classes into a JAR file and load that file into the database.

6.4.1. Loading Individual Class Files

The loadjava command-line utility can be used to load one or more Java class files into the database. The following loadjava command loads the three previously generated class files into the fundamental_user schema. (Note that this is one long command that just happens to wrap to four separate lines in the printed book.)

loadjava -user fundamental_user/fundamental_password -resolve
 ServerExample1.class
 ServerExample1_SJProfileKeys.class
 ServerExample1_SJProfile0.class

The loadjava command-line utility will connect to the database using the username and password specified in the -user option, and then load the specified class files into the database schema. The connection to the database uses the Oracle JDBC OCI driver by default. The -resolve option is used to resolve class references immediately, rather than waiting until each ...

Get Java Programming with Oracle SQLJ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.