This is an old revision of the document!


Development: JDBC Interface

Overview

Omnidex provides a JDBC driver for Java applications against an Omnidex enhanced database, on any supported platform. The Omnidex JDBC driver supports standard JDBC statements and syntax as well as some additional Omnidex specific statements, functions and syntax. See the SQL Reference for a complete list of supported SQL.

The Omnidex JDBC driver is used for all types of Java applications including console apps, swing apps, applets, JSP and Servlets.

The Omnidex JDBC class files are store in a jar file named omnidex.jar, which is located in the bin subdirectory of the Omnidex home directory on the server, or the lib directory of the Omnidex Client home directory on the client machine.

Connecting Through the Omnidex JDBC Driver

Connecting to an Omnidex enhanced database through the Omnidex JDBC driver is the same as connecting to any other database using any other JDBC driver, with three notable exceptions:

The Omnidex JDBC classes and the java.sql classes must be imported into the Java class file. The Omnidex JDBC driver must be loaded and registered with java.sql.DriverManager. The connection url must point to an Omnidex Generic data source. Both the Omnidex JDBC classes and the java.sql classes must be imported into the Java application. This is because the java.sql.DriverManager is used to register the Omnidex JDBC driver and all objects returned are from the java.sql package.

import java.sql.*; import omnidex.jdbc.*;

The following code snippet will load the Omnidex JDBC driver and register it with the java.sql.DriverManager. This ensures that the Omnidex JDBC driver will be used for all subsequent connections.

Class.forName(“omnidex.jdbc.OdxJDBCDriver”);

Pass the connection url to the DriverManager class to obtain a connection.

OdxJDBCConnection conn = (OdxJDBCConnection)DriverManager.getConnection( “jdbc:omnidex:c:\\odxtesting\\dsn\\odx_file_ordersffl.dsn”);

Notice that the Connection object returned by the DriverManager is being cast to an OdxJDBCConnection object. This is because the DriverManager returns a java.sql.Connection, not an omnidex.jdbc.OdxJDBCConnection. All of the Omnidex JDBC Driver classes implement the java.sql classes and inherit all of the constructors, methods and properties. The Omnidex JDBC classes also contain some additional methods a properties specific to Omnidex.

Using the JDBC Interface

Connecting to an Omnidex enhanced database through the Omnidex JDBC driver is the same as connecting to any other database using any other JDBC driver, with two notable exceptions:

  • The Omnidex JDBC driver must be loaded and registered with java.sql.DriverManager.
  • The connection url must point to an Omnidex Generic data source.

The java.sql classes must be imported into the Java program along with any other desired Java packages. This is because the java.sql.DriverManager is used to register the Omnidex JDBC driver. Also, the Omnidex JDBC classes throw java.sql.SQLExceptions.

import java.sql.*;

The following code snippet will load the Omnidex JDBC driver and register it with the java.sql.DriverManager. This ensures that the Omnidex JDBC driver will be used for all subsequent connections.

Class.forName("omnidex.jdbc.OdxJDBCDriver");
// Pass the connection url to the DriverManager class to obtain a connection.
Connection conn = DriverManager.getConnection(
"jdbc:omnidex:c:\\odxtesting\\dsn\\odx_file_ordersffl.dsn");

All of the Omnidex JDBC Driver classes implement the java.sql classes and inherit all of the constructors, methods and properties. The Omnidex JDBC classes also contain some additional methods and properties specific to Omnidex.

Additional Resources

See also:

 
Back to top
dev/jdbc/home.1294862964.txt.gz · Last modified: 2016/06/28 22:38 (external edit)