The DriverManager.getConnection() method

To create a connection to the HCL OneDB™ database or database server, you can use the DriverManager.getConnection() method. This method creates a Connection object, which is used to create SQL statements, send them to the HCL OneDB database, and process the results.

The DriverManager class tracks the available drivers and handles connection requests between appropriate drivers and databases or database servers. The url parameter of the getConnection() method is a database URL that specifies the subprotocol (the database connectivity mechanism), the database or database server identifier, and a list of properties.

A second parameter to the getConnection() method, property, is the property list. See Specify properties for an example of how to specify a property list.

The following example shows a database URL that connects to a database called testDB from a client application:
jdbc:informix-sqli://123.45.67.89:1533/testDB:
   INFORMIXSERVER=myserver;user=rdtest;password=test

The details of the database URL syntax are described in the next section.

The following partial example from the CreateDB.java program shows how to connect to database testDB by using DriverManager.getConnection(). In the full example, the url variable, described in the preceding example, is passed in as a parameter when the program is run at the command line.
try
   {
   conn = DriverManager.getConnection(url);
   }
catch (SQLException e)
   {
   System.out.println("ERROR: failed to connect!");
   System.out.println("ERROR: " + e.getMessage());
   e.printStackTrace();
   return;
   }
Important: The only HCL OneDB connection type supported by HCL OneDB JDBC Driver is tcp. Shared memory and other connection types are not supported. For more information about connection types, see the HCL® OneDB Administrator's Guide for your database server.
Important: Not all methods of the Connection interface are supported by HCL OneDB JDBC Driver. For a list of unsupported methods, see Unsupported methods and methods that behave differently.

Client applications do not need to explicitly close a connection; the database server closes the connection automatically. However, if your application is running in the database server using server-side JDBC, you should explicitly close the connection.