Entering content frame

This graphic is explained in the accompanying text Examples for Connecting to the Database Locate the document in its SAP Library structure

The following connection data is used for the examples listed below:

String username = "TESTUSER";

String password = "TEST";

String database_name = "TST";

String server_name  = "REMOTESERVER";

String sqlmode = "ORACLE";

 

Example 1:

Using getConnection (String url, String user, String password)

The connection options are specified as part of the connection URL.

...

Definition of the connection URL:
String url = "jdbc:sapdb://" + server_name + "/" + database_name + "?sqlmode=" + sqlmode;

Content of the variable url:
"jdbc:sapdb://REMOTESERVER/TST?sqlmode=ORACLE"

Calling the method:
java.sql.Connection conn = java.sql.DriverManager.getConnection (url, username, password);

 

 

Example 2:

Using getConnection (String url)

The connection options, and the name and password of the database user, are specified as part of the connection URL.

...

Definition of the connection URL

String url = "jdbc:sapdb://" + server_name + "/" + database_name + "?sqlmode=" + sqlmode

+ "&user=" + username + "&password=" + password;

Content of the variable url:
"dbc:sapdb://REMOTESERVER"/TST?sqlmode=ORACLE&user=TESTUSER&password=TEST"

Calling the method:

java.sql.Connection conn = java.sql.DriverManager.getConnection (url);

 

 

Example 3:

Using getConnection(String url, Properties info)

The connection options, and the name and password of the database user, are specified in an object of the class java.util.Properties.

...

Definition of the connection URL

String url = "jdbc:sapdb://" + server_name + "/" + database_name;

Content of the connection URL

"jdbc:sapdb://REMOTESERVER/TST"

Creating an object of the class java.util.Properties:

java.util.Properties properties = new java.util.Properties ();

Defining the connection options:

properties.setProperty ("user", username);

properties.setProperty ("password", password);

properties.setProperty ("sqlmode", sqlmode);

Calling the method:

java.sql.Connection conn = java.sql.DriverManager.getConnection (url, properties);

 

 

Leaving content frame