Programmer Guide : solidDB® JDBC Driver : Getting started with solidDB® JDBC Driver
  
Getting started with solidDB® JDBC Driver
The solidDB® JDBC Driver (SolidDriver2.0.jar) is installed during solidDB® installation. You can verify the installation using a sample Java program that is provided in the solidDB® package. Depending on your environment, you may need to set various configuration settings before using the solidDB® JDBC Driver.
Default installation directory
The solidDB® JDBC Driver is installed during the solidDB® server installation into the jdbc directory.
If your application is on a different computer than the solidDB® server, you must copy the JDBC driver file to the computer where the application is located.
Tip:
The jdbc directory contains also the solidDB® Data Store Helper Class (SolidDataStoreHelper.jar) for use with WebSphere®.
The samples/jdbc directory in the solidDB® installation directory contains Java code samples that use the solidDB® JDBC Driver. Instructions for running the sample are available in the readme.txt file, which is available in the same directory.
Requirements for Java environment
Ensure that you have a working Java runtime or development environment that supports JDBC API specification release 2.0.
Check from your Java environment documentation whether it can use compressed bytecode. The SolidDriver2.0.jar contains the solidDB® JDBC Driver classes in compressed bytecode format usable by most Java virtual machines. However, some environments (such as Microsoft J++) require uncompressed bytecode. If your environment requires uncompressed bytecode, you must extract the SolidDriver2.0.jar file by using a tool that supports long file names.
Setting the CLASSPATH environmental variable
The CLASSPATH environment variable for your environment must include the solidDB® JDBC Driver .jar file installation path.
Windows
The installation adds the default solidDB® JDBC Driver installation path to the System CLASSPATH environment variable automatically.
You can check and set the System CLASSPATH environment variable through the Control Panel:
Control Panel > System > Advanced > Environment Variables
Linux and UNIX
Set your CLASSPATH environment variable to include the solidDB® JDBC Driver (SolidDriver2.0.jar) installation path.
For example, in Bourne shell, use the following command:
export CLASSPATH=<solidDB® installation directory>
    /jdbc/SolidDriver2.0.jar:$CLASSPATH
If you are using another shell than the Bourne shell, modify this command to make it appropriate for your shell.
Verifying the installation with sample1.java
The sample1.java sample application (available in the samples/jdbc directory) can be used for validating the solidDB® JDBC Driver installation.
The sample1.java sample application performs the following actions:
1 Registers the solidDB® JDBC Driver using JDBC Driver Manager services.
2 Asks for the connect string for a running solidDB® process.
3 Connects to solidDB® using the driver.
4 Creates the following statement for one query for retrieving data from one of the solidDB® system tables:
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,
  TABLE_TYPE FROM TABLES
5 Executes the query.
6 Fetches all the rows of a result set. An empty solidDB® database dictionary contains approximately 86 rows.
Running the sample
Before running the sample, check the following:
Your PATH environment variable contains the directories that hold the Java compiler and JRE.
The samples/jdbc directory contains a valid solidDB® (evaluation) license.
1 If you do not already have a solidDB® process running, start it now and create an empty database.
2 Change your working directory to /samples/jdbc, which is the directory that contains the sample Java program.
3 Compile the Java sample program: javac sample1.java
4 Start the sample application with the command:
java sample1
5 The application prompts for a valid connect string. The connect string format is: jdbc:solid://<hostname>:<port>/<username>/<password>
For example, the following string attempts to connect to a solidDB® server at host “mymachine” which listens to TCP/IP protocol at port 2315.
jdbc:solid://localhost:2315/dba/dba
After entering the connect string, the sample application outputs the query results.
Troubleshooting the sample1.java sample application
Possible problems in running the sample1.java sample application and solutions for them are listed below:
1 The driver cannot be successfully registered.
The Java environment does not support java.sql classes.
SolidDriver2.0.jar is not in the CLASSPATH definition.
2 Unable to connect to solidDB® process
The version of the solidDB® server should be 100 or later.
Older solidDB® versions may refuse connections from the driver that is provided with the current release.
The connect string may be wrong or solidDB® may not be listening to the specified TCP/IP.
Check that solidDB® is running and verify the listening information. You can use, for example, solidDB® SQL Editor (solsql) to ensure that a connection can be established through the network.
See also
Registering solidDB® JDBC Driver
Connecting to the database
solidDB® JDBC Driver