JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1

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 for the MXCS association
server, the database schema and catalog names, the location of the database server, the name
of the database, and so forth.
NOTE: When a JDBC application uses any server (MXCS) data source, including the default
data source, the data source must have been started by MXCS. For more information, see the HP
NonStop Connectivity Service Manual for SQL/MX Release 3.2.1.
For details about Type 4 driver properties that you can use with the DataSource object, see
“Type 4 Driver Properties” (page 33).
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 SQLMXDataSource object or the SQLMXConnectionPoolDataSource object.
For example,
SQLMXDataSource temp = new SQLMXDataSource();
temp.setCatalog("abc");
In the following example, the code fragment illustrates the methods that a DataSource object ds
needs to include if the object supports the property serverName.
ds.setServerName("my_database_server");
In the following example, the code shows setting properties for the SQLMXDataSource object to
use the Type 4 driver to access an SQL/MX database:
SQLMXDataSource ds = new SQLMXDataSource();
ds.setUrl("jdbc:t4sqlmx://mynode.mycompanynetwork.net:port_number/";
ds.setCatalog("mycat");
ds.setSchema("myschema"); ds.setUser("lee");
ds.setPassword("safeguard password");
// 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");
Programmatically Registering the DataSource Object
In the following example, the code shows how to register, programmatically, the
SQLMXDataSource 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");
javax.naming.Context ctx = new javax.naming.InitialContext(env);
ctx.rebind("myDataSource", ds);
22 Accessing SQL Databases with SQL/MX