Variables used, connection options and example data
Variable |
Meaning |
Connection option |
Example |
|
Name of the database user |
username |
MONA |
|
Password of the database user |
password |
RED |
<database_name> |
Name of database instance |
|
DEMODB |
<database_computer> |
Name of the computer on which the database instance is running |
|
PARMA |
|
SQL mode |
sqlmode |
ORACLE |
You use getConnection (String url, String user, String password). The connection options are specified as part of the connection URL.
...
1.
Content of the
variable url:
"jdbc:sapdb://PARMA/DEMODB?sqlmode=ORACLE"
2.
Calling the
method:
java.sql.Connection conn =
java.sql.DriverManager.getConnection (url, username, password);
You use getConnection (String url). The connection options, name and password of the database user are specified as part of the connection URL:
...
1.
Content of the
variable url:
"jdbc:sapdb://PARMA/DEMODB?sqlmode=ORACLE&user=MONA&password=RED"
2. Calling the method:
java.sql.Connection conn = java.sql.DriverManager.getConnection (url);
You use getConnection(String url, Properties info). The connection options, name and password of the database user are transferred in an object of the java.util.Properties class.
...
1. Content of the connection url:
"jdbc:sapdb://PARMA/DEMODB"
2.
Creating an
object of the class java.util.Properties:
java.util.Properties properties = new java.util.Properties ();
3. Defining the connection options:
properties.setProperty ("user", "MONA");
properties.setProperty ("password", "RED");
properties.setProperty ("sqlmode", "ORACLE");
4. Calling the method:
java.sql.Connection conn = java.sql.DriverManager.getConnection (url, properties);