Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
finds a suitable driver that recognizes this URL and obtains a database connection using that
driver.
com.hp.t4jdbc.HPT4Driver is the Type 4 driver class that implements the java.sql.Driver
interface.
Topics included in this subsection are:
• “Loading and Registering the Driver” (page 25)
• “Establishing the Connection” (page 25)
• “Guidelines for Connections Using the Driver Manager” (page 25)
Loading and Registering the Driver
Before connecting to the database, the application loads the Driver class and registers the Type
4 driver with the DriverManager class in one of the following ways:
• Specifies the Type 4 driver class in the -Djdbc.drivers option in the command line of
the Java program:
-Djdbc.drivers=com.hp.t4jdbc.HPT4Driver
• Uses the Class.forName method programmatically within the application:
Class.forName("com.hp.t4jdbc.HPT4Driver")
• Adds the Type 4 driver class to the java.lang.System property jdbc.drivers property
within the application:
jdbc.drivers=com.hp.t4jdbc.HPT4Driver
Establishing the Connection
The DriverManager.getConnection method accepts a string containing a Type 4 driver
URL. The JDBC URL for the Type 4 driver is
jdbc:hpt4jdbc://ip_addr_or_host_name:18650/[:][property=value[;property2=value2]...]
ip_addr_or_host_name
is the primary IP address or host name for
the Neoview database.
18650
is the port number for the Neoview SQL
database.
property = value and
property2=value2
specify a Type 4 driver property
name-property value pair. The pairs must
be separated by a semicolon (;). For
example,
T4LogLevel=ALL;T4LogFile=temp1.log
For information about the properties file, see Chapter 4 (page 35).
To establish a connection, the JDBC application can use this code:
Class.forName("com.hp.t4jdbc.HPT4Driver"); //loads the driver
String url = "jdbc:hpt4jdbc://primary_IP_addr_on_Neoview_DB:18650/"
Connection con = DriverManager.getConnection(url, "userID", "Passwd");
The variable con represents a connection to the data source that can be used to create and execute
SQL statements.
Guidelines for Connections Using the Driver Manager
• The Type 4 driver defines a set of properties that you can use to configure the driver. For
detailed information about these properties, see Chapter 4 (page 35).
• Java applications can specify the properties in these ways (listed in the order of precedence):
Connection by Using the DriverManager Class 25