Several variations of the call needed to connect to the database follow:
Variation 1:
Connection con = DriverManager.getConnection ( url, myuserid, mypassword );
This is an example of how to connect to the OpenEdge database using Variation 1:
String url;
String myuserid;
String mypassword;
url = new String ( "jdbc:datadirect:openedge://myhost:6718;databaseName=sports2000" );
myuserid = new String ( "jones" );
mypassword = new String ( "secret" );
Connection con = DriverManager.getConnection ( url, myuserid,
mypassword );
Variation 2:
Connection con = DriverManager.getConnection ( url, info );
In this variation info is a Properties object that contains a string of tag/value pairs used for connecting to the database. Normally the info object would include at least the user ID and password. The password is optional and defaults to NULL. However, once the CREATE USER statement has been executed and a user is created in the database, a password is required.
The JDBC driver expects the user ID tag to be named user and the password tag to be named password. The user and password tags are case-sensitive and must be in all lowercase letters.
This is an example of how to connect to the database using Variation 2 (tag/value pairs):
String url;
String myuserid;
String mypassword;
url = new String ( "jdbc:datadirect:openedge://myhost:6718;databaseName=sports2000" );
myuserid = new String ( " jones " );
mypassword = new String ( "secret " );
java.util.Properties info = new java.util.Properties ( );
info.put ( " user ", myuserid );
info.put ( " password ", mypassword );
Connection con = DriverManager.getConnection ( url, info );
Variation 3:
Connection con = DriverManager.getConnection ( url );
This variation takes only the URL as an argument. The URL in this case contains the user and password tags shown in Variation 2. The password is optional and defaults to NULL. However, once the CREATE USER statement has been executed and a user is created in the OpenEdge database, a password is required.
The JDBC driver expects the user ID tag to be named user and the password tag to be named password. The user and password tags are case sensitive and must be in all lowercase letters.
This is an example of how to connect to the OpenEdge database using Variation 3:
String url;
url = new String ( "jdbc:datadirect:openedge://myhost:6718;databaseName=sports2000;
user = jones ; password = secret" );
Connection con = DriverManager.getConnection ( url );
JDBC URL connection string
The OpenEdge JDBC URL string has the following syntax:
jdbc is the protocol to be used. The protocol in a JDBC URL is always jdbc.
datadirect is the subprotocol and it designates the name of the JDBC driver.
openedge indicates that the driver is for OpenEdge.
host
The name of the host on which the OpenEdge database resides. If this is not specified it defaults to localhost (localhost is valid only if the database is not remote). The host is myhost in the example.
port
Port number or service name to be used for the connection. The port is 6718 in the first example.
Note: If you specify the service_name, the port must be -1, as shown in the second example.
db_name
The name of the database. The db_name is sports2000 in the example.
service_name
An optional parameter, indicating the name of the service. The service_name is myservice in the example. If you specify service_name, the port must be -1.
schema_name
Indicates the schema to be used during statement processing. For more information about the defaultSchema connection parameter, see the .
CacheSize
Indicates how many entries will be in the statement cache. For more information about the statementCacheSize connection parameter, see the .