External Interfaces > Reality Java Interface > SQL/JDBC Interface to Reality > Connection Examples

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

RealityV15.1Online Documentation (MoTW) Revision 7

Connection Examples (RealSQL-JDBC) (connexam.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

Connection Examples

Method A
String driver = "com.northgateis.reality.realsql.RealSQLDriver";
String url = "jdbc:realsql://magpie:1203/TESTDBASE;" +
  "user=ajt,password=a23Fgh,account=SQL-TEST,accountpwd="
// Connect to the database
try {
   Class.forName(driver);
   connection = DriverManager.getConnection(url);
}
catch( SQLException e ) {
   System.out.println("Failed to connect: " + e.getMessage());
   return;
}
catch( ClassNotFoundException e ) {
   System.out.println("Unable to find driver class.");
   return;
}
System.out.println("Connected to the database.");
Method B
String driver = "com.northgateis.reality.realsql.RealSQLDriver";
String url = "jdbc:realsql://magpie:1203/TESTDBASE";
String user="ajt";
String userpwd="a23Fgh";
String account="SQL-TEST";
String accountpwd="";
Properties info = new Properties();
info.put("user", user);
info.put("password", userpwd);
info.put("account", account);
info.put("accountpwd", accountpwd);
info.put("logLevel", "INFO");
info.put("logOptions", "METHODS");
info.put("logModules", "CONNECTION|DATABASEMETADATA");
PrintWriter pw = new PrintWriter(System.out);
DriverManager.setLogWriter(pw);
// Connect to the database
try {
   Class.forName(driver);
   connection = DriverManager.getConnection(url, info);
}
catch( SQLException e ) {
   System.out.println("Failed to connect: " + e.getMessage());
   return;
}
catch( ClassNotFoundException e ) {
   System.out.println("Unable to find driver class.");
   return;
}
System.out.println("Connected to the database.");
Method C
String driver = "com.northgateis.reality.realsql.RealSQLDriver";
String url = "jdbc:realsql://magpie:1203/TESTDBASE;" +
   "account=SQL-TEST,accountpwd=,logModules=DDA"
String user="ajt";
String password="a23Fgh";
PrintWriter pw = new PrintWriter(System.out);
DriverManager.setLogWriter(pw);
// Connect to the database
try {
   Class.forName(driver);
   connection = DriverManager.getConnection(url, user, password);
}
catch( SQLException e ) {
   System.out.println("Failed to connect: " + e.getMessage());
   return;
}
catch( ClassNotFoundException e ) {
   System.out.println("Unable to find driver class.");
   return;
}
System.out.println("Connected to the database.");

RealityV15.1 (MoTW) Revision 7Comment on this topic