Database connection examples
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Database connection examples
Several variations of the call needed to connect to the database follow:
- Variation 1:
|
This is an example of how to connect to the OpenEdge database using Variation 1:
|
- Variation 2:
|
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):
|
- Variation 3:
|
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:
|
- JDBC URL connection string
The OpenEdge JDBC URL string has the following syntax:
|
This is an example of a connection string:
|
This is an example of a connection string, using the optional service_name parameter:
|
The components of the URL string are:
-
jdbc:datadirect:openedge:// -
jdbcis the protocol to be used. The protocol in a JDBC URL is alwaysjdbc. -
datadirectis the subprotocol and it designates the name of the JDBC driver. -
openedgeindicates 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(localhostis valid only if the database is not remote). Thehostismyhostin the example. - port
-
Port number or service name to be used for the connection.
The
portis6718in 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
sports2020in the example. - service_name
-
An optional parameter, indicating the name of the service.
The service_name is
myservicein 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
defaultSchemaconnection parameter, see the . - CacheSize
-
Indicates how many entries will be in the statement cache.
For more information about the
statementCacheSizeconnection parameter, see the .