Connecting to External Database with JDBC
LDL++ comes with a Java LDL++ driver (JavaLdlServer.class) that
connects to external databases using JDBC. LDL++ will talk with this
driver which in turn talks with external databases.
Configure Java LDL++ driver
The Java LDL++ driver is configured by editing file
"jdbc.server" which must be in the same directory as the driver (JavaLdlServer.class). A sample configuration file looks like the following:
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 driver line (starts with "mysql.driver" for MySQL) specifies the JDBC
driver used by the Java LDL++ driver and the URL line (starts with "mysql.url" for MySQL)
specifies the protocol and the host the MySQL database is running on.
Using External Database via JDBC
The following syntax is used in the LDL++ program to use JDBC external database.
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 local name "emp". "vesuvio.cs.ucla.edu" is
the machine the Java LDL++ driver is running on.
The following example tries to connect to 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
} ).
Last modified: Thu Jul 16 11:40:26 1998