Previous: External Databases Table of Contents Next: Foreign Language Functions    Connecting to External Database with JDBC

The Java LDL++ driver (JavaLdlServer.class) connects to external databases using JDBC. LDL++ communicates with this driver which in turn communicates with external databases.

Configuring a Java LDL++ driver

The Java LDL++ driver is configured by editing file "jdbc.server" which must be in the same directory as the driver (JavaLdlS erver.class). The following is a sample configuration for an MySQL database and an Oracle server:

mysql.driver = twz1.jdbc.mysql.jdbcMysqlDriver 

mysql.url = jdbc:z1MySQL://vesuvio.cs.ucla.edu:3306/test  oracle.driver = oracle.jdbc.OracleDriver oracle.url = jdbc:oracle:

Basically, the configuration specifies two things. One is the jdbc driver, the other is the URL of the database server. This Java LDL++ driver is configured to talk with MySQL and Oracle database server. The line starting with "mysql.driver" specifies the JDBC specifies the JDBC/MySQL driver. The line starting with "mysql.url" specifies the URL and the protocol for the MySQL system.

Using External Database via JDBC

The following syntax is used in the LDL++ schema to denote an exteranal database accessible via JDBC:

database( {
        jdbc::employee(Name:string, Dept:string, Sal:integer)
                local_name emp
                from 'vesuvio.cs.ucla.edu:mysql'
                user_name hxwang
                password lapid
        } ).

Here, "employee" is a table managed by MySQL and is refered by this LDL++ program with the local name of "emp". Also, "vesuvio.cs.ucla.edu" is {\em the machine where the Java LDL++ driver is running on}.

The next example showa a connection to an Oracle server. The Java LDL++ driver in this example is running on "cheetah.cs.ucla.edu". 

database( {
        jdbc::temp2(Name: integer)
                local_name temp
                from 'cheetah.cs.ucla.edu:oracle'
                user_name hxwang
                password dbpasswd,
        jdbc::temp5(ID: integer, NAME:varchar, SALARY:float)
                local_name emp
                from 'cheetah.cs.ucla.edu:oracle'
                user_name hxwang
                password dbpasswd
        } ).



Next Page Top of Page
Carlo Zaniolo. Jul,1998