Description of the Example Application
The example application, ExampleApp, connects to a Reality database and executes an SQL query to list all items in the table of employees. This example application
-
Loads the Reality SQL/JDBC driver class into memory:
com.northgateis.reality.realsql.RealSQLDriver -
Compiles a URL in the required format -
jdbc:realsql://magpie:1203/TESTDBASE- to connect to the Reality databaseTESTDBASEon themagpiesystem. -
Builds a
java.util.Propertiesobject to store the connection properties. These properties comprise the user-id and password on the remote host and database, and the name of the Reality account.accountpwdis set to null because there is no password for this account. -
Calls one of the
DriverManager.getConnection()methods, passing the URL and the connection properties. -
Calls
createStatement()in theConnectionclass to create a statement object for sending the SQL query to the database. -
Passes the SQL query "SELECT * FROM EMP" into the
Statement.executeQuery()method, which returns a single result set. -
Retrieves the
ResultSetMetaDataobject created during theexecuteQuery()from theResultSetobject. -
Calls methods in the
ResultMetaDataclass (getColumnCount(),getColumnDisplaySize()andgetColumnLabel()) to retrieve the column property information, then calls methods inResultSetto retrieve the column data for all rows in EMP.