SQL/JDBC Interface to Reality

The SQL/JDBC interface to Reality comprises a package of Java classes: com.northgateis.reality.realsql. Links to the JavaDocs for these classes are provided in this guide, see JavaDocs for Reality SQL/JDBC Interface Classes. The classes can be instantiated by a Java application, applet or servlet and their methods can be called to

The following code fragment gives a basic example of these three steps: (for a complete example program, see Example Application Using SQL/JDBC)

// Load the driver class into memory.
// On loading, the driver automatically registers itself with the DriverManager.
Class.forName("com.northgateis.reality.realsql.RealSQLDriver");
// Create a database URL. The URL has three components:
// - The connection protocol, in this case jdbc
// - A subprotocol identifying the driver to use, in this case realsql
// - A subname, identifying any remaining connection properties. In this example,
//   these properties request connection to the account SQL-TEST, which resides
//   on the Reality database TESTBASE on the host server myst, on port 1203. (The
//   port number is optional, 1203 is the default.)
String url = "jdbc:realsql://myst:1203/TESTDBASE;account=SQL-TEST";
// Call a getConnection() method via the DriverManager class (see RealSQLDriver)
// to establish a connection to the database using the URL above together with
// a userid and password.
Connection con = DriverManager.getConnection(url, "userid", "password");
// Create a Statement object
Statement stmt = con.createStatement();
// Use the statement object to execute an SQL query and return the results into
// a new ResultSet object
ResultSet rs = stmt.executeQuery("SELECT * FROM EMP");
// Process the result by iterating through each row of the ResultSet
while (rs.next()) {
    int eID = getInt("EMPNO");
    String eName = getString("ENAME");
    BigDecimal eSal = getDecimal("SAL");
}

For more information on how the Reality SQL/JDBC interface operates and details of the standards supported, please refer to Introduction to SQL for Reality in SQL for Reality.

For a Reality database to be used as an SQL catalog, files must exist that define the Reality files as SQL tables columns and indexes. For more information, refer to Accessing Reality Files via SQL in SQL for Reality.

The Reality SQL/JDBC Driver is installed as a JAR file: realsql-jdbc.jar.

For a list of the Java interfaces implemented by the driver, see JDBC Interfaces.