User's Guide
PART 3. Java in the Database
CHAPTER 17. Using Java in the Database
This chapter describes how to accomplish tasks using Java in the database, including the following:
How to Java-enable a database You need to take certain steps to enable your database to use Java.
Installing Java classes You need to install Java classes in a database to make them available for use in the server.
Properties of Java columns This section describes how columns with Java class data types fit into the relational model.
Java database design This section provides tips for designing databases that use Java classes.
Many of the examples in this chapter are carried out using a set of classes and tables added to the sample database. The tables hold the same information as tables of the same name in the sample database, but they are owned by a user ID named jdba. They use Java class data types instead of simple relational types to hold the information.
Sample tables designed for tutorial use only |
Connect to the sample database from Interactive SQL, using the user ID DBA and password SQL, ensuring that the database server has 8 Mb of cache available.
You can do this by starting Interactive SQL from the Start menu, and selecting the ASA 6.0 Sample data source in the Connection window.
Alternatively, you can start Interactive SQL from the command line, connecting to the ASA 6.0 Sample data source:
dbisql -c "dsn=ASA 6.0 Sample"
In Interactive SQL, enter the following statement:
READ "path\jxmp\jdemo.sql"
where path is your Adaptive Server Anywhere installation directory. This runs the instructions in the jdemo.sql command file. The instructions may take some time to complete.
You can view the jdemo.sql script using a text editor. It uses out the following steps:
Installs the JDBCExamples class.
Creates a user ID named JDBA with password SQL and DBA authority, and sets the current user to be jdba.
Installs a JAR file named asademo.jar. This file contains the class definitions used in the tables.
Creates the following tables under the jdba user ID:
product
contact
customer
employee
sales_order
sales_order_items
This is a subset of the tables in the sample database.
Adds the data from the standard tables of the same names into the Java tables. This step uses INSERT from SELECT statements. This step may take some time.
Creates some indexes and foreign keys to add integrity constraints to the schema.