Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
An instance of the DataSource class and the DataSource object properties are usually set by
an application developer or system administrator using a GUI tool as part of the installation of
the data source. If you are using an installed data source, see “Programmatically Creating an
Instance of the DataSource Class” (page 23).
The subsequent topics show an example of performing these tasks programmatically.
For more information about using data sources, see The JDBC Tutorial: Chapter 3- Advanced
Tutorial (http://java.sun.com/developer/Books/JDBCTutorial/index.html) or other information
available in the field.
DataSource Object Properties
A DataSource object has properties that identify and describe the actual data source that the
object represents. These properties include such information as the URL (the primary IP address
or host name on the Neoview SQL database) , the database schema and catalog names, the
location of the database server, the name of the database, and so forth.
For details about Type 4 driver properties that you can use with the DataSource object, see
Chapter 4 (page 35).
Programmatically Creating an Instance of the DataSource Class
A JDBC application can set DataSource properties programmatically and register with a
DataSource object.
To get or set DataSource object properties programmatically, use the appropriate getter or
setter methods on the HPT4DataSource object or the HPT4ConnectionPoolDataSource
object. For example:
HPT4DataSource temp = new HPT4DataSource();
temp.setCatalog("Neo");
In the following example, the code fragment illustrates the methods that a DataSource object
ds needs to include if the object supports the serverDataSource property.
ds.setServerDataSource("my_server_datasource")
In this example, the code shows setting properties for the HPT4DataSource object to use the
Type 4 driver to access a Neoview SQL database:
HPT4DataSource ds = new HPT4DataSource();
ds.setUrl("jdbc:hpt4jdbc://<primary_IP_addr_or_host_name_on_Neoview_DB>:18650/";
ds.setCatalog("NEO");
ds.setSchema("myschema");
ds.setUser("lee");
ds.setPassword("my_userpassword");
// Properties relevant for Type 4 connection pooling.
// Set ds.setMaxPoolSize(-1) for turning OFF connection pooling
ds.setMaxPoolSize("10000");
ds.setMinPoolSize("1000");
// Properties relevant for Type 4 statement pooling.
// Set ds.setMaxStatement(0) for turning statement pooling OFF
// Statement pooling is enabled only when connection pooling is
// enabled.
ds.setMaxStatements("7000");
This technique essentially builds a properties file. For more information, see “Creating and Using
a Properties File” (page 38).
Programmatically Registering the DataSource Object
In the following example, the code shows how to register, programmatically, the
HPT4DataSource object ds that was created using the preceding code with JDNI.
java.util.Hashtable env = new java.util.Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
Connection by Using the DataSource Interface 23