Skip to content

Commit be6367e

Browse files
authored
Update JDBCDBTokenSample.java
1 parent 24e9f34 commit be6367e

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

java/jdbc/ConnectionSamples/JDBCDBTokenSample.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
/*
44
DESCRIPTION
55
The code sample shows how to use the JDBC driver to establish a connection
6-
to the Autonomous Database (ADB) using database token
6+
to the Autonomous Database (ADB) using access token
77
issued by the OCI Identity service.
8-
9-
You need to use either JDBC driver to use
10-
database token authenticatio.
118
12-
Step 1: Enter the DB_URL to pointing to your Autonomous Database (ADB)
13-
Step 2: Make sure to have either 21.4.0.0.1 or 19.13.0.0.1 JDBC driver
14-
in the classpath.
15-
Step 2: Compile and Run the sample JDBCDBTokenSample
9+
Step 1: Enter the DB_URL to pointing to your Autonomous Database (ADB)
10+
Step 2: Make sure to have either 21.4.0.0.1 or 19.13.0.0.1 JDBC driver
11+
in the classpath.
12+
Step 3: Compile and run the sample JDBCDBTokenSample
1613
1714
NOTES
18-
Use JDK 1.7 and above
15+
Use JDK8 and above
1916
MODIFIED (MM/DD/YY)
2017
nbsundar 1/7/21 - Creation
2118
*/
@@ -38,26 +35,25 @@ public class JDBCDBTokenSample {
3835
// Download the wallet zip file and provide the path to the zip file as TNS_ADMIN
3936
// Note that you need to pass the property oracle.jdbc.tokenAuthentication=OCI_TOKEN for token authentication
4037
final static String DB_URL="jdbc:oracle:thin:@dbname_high?TNS_ADMIN=/Users/user/wallet/Wallet_dbname&oracle.jdbc.tokenAuthentication=OCI_TOKEN";
41-
// If mutla TLS(mTLS) is disabled then, ADB connection does not require wallets.
38+
// If mutual TLS(mTLS) is disabled then, ADB connection does not require wallets.
4239
// Copy the connection string from "DB Connection" tab from "Connection Strings" section choosing "TLS" in the dropdown
4340
//final static String DB_URL="jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=gebqqeredfsozhjbqbs_dbname_medium.adb.oraclecloud.com)))?oracle.jdbc.tokenAuthentication=OCI_TOKEN";
41+
// Another way to enable token authentication in the long form connection string.
42+
final static String DB_URL="jdbc:oracle:thin:@(description="
43+
+ "(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.us-phoenix-1.oraclecloud.com))"
44+
+ "(security=(token_auth=OCI_TOKEN))"
45+
+ "(connect_data=(service_name=gebqqeredfsozhjbqbs_dbname_medium.adb.oraclecloud.com)))?oracle.jdbc.tokenAuthentication=OCI_TOKEN";
4446

4547

4648
public static void main(String args[]) throws SQLException {
4749

4850
// For more connection related properties. Refer to
4951
// the OracleConnection interface.
5052
Properties properties = new Properties();
51-
52-
properties.put(OracleConnection.CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH, "20");
53-
properties.put(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_TYPES,
54-
"(MD5,SHA1,SHA256,SHA384,SHA512)");
55-
properties.put(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_LEVEL,
56-
"REQUIRED");
57-
// Connection property to enable database token authentication.
53+
54+
//Connection property to enable IAM token authentication.
5855
// properties.put(OracleConnection.CONNECTION_PROPERTY_TOKEN_AUTHENTICATION, "OCI_TOKEN");
59-
60-
56+
6157
OracleDataSource ods = new OracleDataSource();
6258
ods.setURL(DB_URL);
6359
ods.setConnectionProperties(properties);

0 commit comments

Comments
 (0)