JDBC Server Programmer's Reference
allowing the distributed garbage collector to perform garbage collection on these objects. This method also aborts any
transactions associated with the Connection that are still active. (As long as a transaction remains active, it maintains database
locks, thus preventing other applications or clients from accessing the data).
To assist in remote cleanup, you should explicitly drop any remote reference in the client program. This means that you close
all resultSets, statements, preparedStatements, and Connections. You should also set these objects to null after you close them.
You can also force the garbage collector to run before you exit the client program by using System.gc().
Starting the Client
Before you start a client program, you must have the t3client.jar file in your CLASSPATH. In addition, if the JDBC
Server has been started with the -Denc_password=true System Property specified and user authentication is required,
you must specify the -Denc_password=true System Property when you start a client program. For example:
java -Denc_password=true TestClient ... // if the JDBC Server was started with the
-Denc_password property
or
java TestClient ... // if the -Denc_password property was not specified when starting
the JDBC Server
Loading the Client Driver
The client program loads the Type 3 JDBC driver in one of the following ways:
Names the driver on the command line when starting the Java Runtime:
java -Djdbc.drivers=com.tandem.jdbc.t3client.driver
●
Adds the driver to java.lang.System property jdbc.drivers:
Properties prop=new Properties();
prop.put("jdbc.drivers","com.tandem.jdbc.t3client.driver");
System.setProperties(prop);
●
Calls Class.forName() with the name of the driver:
Class.forName("com.tandem.jdbc.t3client.driver");
●
Connecting to the Database
The client program connects to a NonStop SQL database on the Compaq server using the
DriverManager.getConnection() method which takes a Java String specifying the database's URL.
The URL of the database must have the following format:
"t3jdbc:sqlrmi:" + "//" + "host_name" [:"port_number"] + "/" + "jdbc_database_url"
t3jdbc and sqlrmi are the protocol and subprotocol, respectively, of the Type 3 JDBC client driver, host_name is the
name of the host machine where the target JDBC Server daemon is running, and port_number is the number of the port at
which rmiregistry is running on the host machine. (You do not need to specify port_number if rmiregistry is
running on its default port, 1099).
The full JDBC URL used to connect to a database is jdbc:sqlmp (for an SQL/MP database) or jdbc:sqlmx (for an
SQL/MX database).
For example, to connect to a NonStop SQL/MX database running on the host ServerHost, using the default port, use the
URL: t3jdbc:sqlrmi://ServerHost/jdbc:sqlmx:.