How to Set Up your Environment
This section contains information about proper configuration for use of the JDBC interface.
Setting the CLASSPATH
So that Java applications and applets recognize the PSQL JDBC Driver, set your CLASSPATH environment variable to include the pvjdbc2.jar, pvjdbc2x.jar, and jpscs.jar files. By default, these files are installed on Windows platforms in the install_directory\bin folder under Program Files. On Linux and OS X, the files are installed by default to /usr/local/psql/bin/lib.
From Windows
set CLASSPATH=%CLASSPATH%;<path to pvjdbc2.jar directory>/pvjdbc2.jar
set CLASSPATH=%CLASSPATH%;<path to pvjdbc2x.jar directory>/pvjdbc2x.jar
set CLASSPATH=%CLASSPATH%;<path to jpscs.jar directory>   /jpscs.jar
From Linux and OS X
export CLASSPATH=$CLASSPATH:<path to pvjdbc2.jar directory>/pvjdbc2.jar
export CLASSPATH=$CLASSPATH:<path to pvjdbc2x.jar directory>/pvjdbc2x.jar
export CLASSPATH=$CLASSPATH:<path to jpscs.jar directory>/jpscs.jar
Setting the SYSTEM PATH
If you connect to the database engine using shared memory or IPX, the JDBC driver must find pvjdbc2.dll. Ensure that your PATH variable on Windows contains the location of the DLL:
set PATH=%PATH%;<path to pvjdbc2.dll directory>
If you connect to the database engine using sockets, typically no DLL is required.
Loading the JDBC Driver into the Java Environment
After setting the CLASSPATH, you can now reference the PSQL JDBC Driver from your Java application. You do this by using the java.lang.Class class:
Class.forName("com.pervasive.jdbc.v2.Driver");
IPv6 Environments
If you want to use the PSQL JDBC driver in an IPv6-only environment, we recommend that you also use Java JRE 1.7. You may encounter issues with license counts or client-tracking problems if your application uses Java JRE 1.6 or earlier in an IPv6-only environment.
You may also encounter issues with license counts for the following combination of conditions:
1
2
The SYSTEM PATH on the machine does not include the location of pvjdbc2.dll. See also Setting the SYSTEM PATH.
Specifying a Data Source
After loading the PervasiveDriver class into your Java environment, you need to pass a URL-style string to the java.sql.DriverManager class to connect to a PSQL database. The syntax for URL for the JDBC driver is:
jdbc:pervasive://<machinename>:<portnumber>/<datasource>
For example, if your PSQL engine is on a machine named DBSERV, and you wish to connect to the DEMODATA database, your URL would look like this (assuming the server is configured to use the default port):
jdbc:pervasive://DBSERV/DEMODATA
So to connect to the database using the DriverManager class, you would use the syntax:
Connection conn = DriverManager.getConnection("jdbc:pervasive://DBSERV:1583/DEMODATA", loginString, passwordString);
where "loginString" is the string that represents a user login and "passwordString" is the string that represents a user password.
*Note: The PSQL engine must be running on the specified host for JDBC applets and applications to access data.
Developing JDBC Applets
To develop web based applications using JDBC, you need to place the JDBC jar file in the codebase directory containing the applet classes.
For example, if you are developing an application called MyFirstJDBCapplet, you need to place the pvjdbc2.jar file in the directory containing the MyFirstJDBCapplet class. For example, it might be C:\inetpub\wwwroot\myjdbc\.
This enables the client web browser to be able to download the JDBC driver over the network and connect to the database.
You also need to put the archive parameter within the <APPLET> tag. For example:
<applet CODE="MyFirstJDBCapplet.class"
ARCHIVE="pvjdbc2.jar" WIDTH=641 HEIGHT=554>
Note that the PSQL engine must be running on the Web server that hosts the applet.