Skip to content

Commit b0de77d

Browse files
authored
Update ADBQuickStart.java
changes per review comments
1 parent c47165b commit b0de77d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

java/jdbc/ConnectionSamples/ADBQuickStart.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public class ADBQuickStart {
5555
public static void main(String args[]) throws Exception {
5656
// Make sure to have Oracle JDBC driver 18c or above
5757
// to pass TNS_ADMIN as part of a connection URL.
58-
// TNS_ADMIN - Should be the path where the client credentials zip file is downloaded.
58+
// TNS_ADMIN - Should be the path where the client credentials zip (wallet_dbname.zip) file is downloaded.
59+
// dbname_medium - It is the TNS alias present in tnsnames.ora.
5960
final String DB_URL="jdbc:oracle:thin:@dbname_medium?TNS_ADMIN=/Users/test/wallet_dbname/";
6061
// Update the Database Username and Password to point to your Autonomous Database
6162
final String DB_USER = "admin";
@@ -100,16 +101,13 @@ public static void main(String args[]) throws Exception {
100101
System.out.println("Available connections after checkout: "
101102
+ pds.getAvailableConnectionsCount());
102103
System.out.println("Borrowed connections after checkout: "
103-
+ pds.getBorrowedConnectionsCount());
104-
104+
+ pds.getBorrowedConnectionsCount());
105105
// Perform a database operation
106-
try {
107106
doSQLWork(conn);
108107
} catch (SQLException e) {
109108
System.out.println("ADBQuickStart - "
110109
+ "doSQLWork()- SQLException occurred : " + e.getMessage());
111-
}
112-
}
110+
}
113111

114112
System.out.println("Available connections after checkin: "
115113
+ pds.getAvailableConnectionsCount());
@@ -124,15 +122,15 @@ private static void doSQLWork(Connection conn) throws SQLException {
124122
String queryStatement = "SELECT CUST_ID, CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY,"
125123
+ "CUST_CREDIT_LIMIT FROM SH.CUSTOMERS WHERE ROWNUM < 20 order by CUST_ID";
126124

127-
System.out.println("Query is " + queryStatement);
125+
System.out.println("\n Query is " + queryStatement);
128126

129127
conn.setAutoCommit(false);
130128
// Prepare a statement to execute the SQL Queries.
131129
try (Statement statement = conn.createStatement();
132130
// Select 20 rows from the CUSTOMERS table from SH schema.
133131
ResultSet resultSet = statement.executeQuery(queryStatement)) {
134-
System.out.println("\nCUST_ID" + " " + "CUST_FIRST_NAME" + " " + "CUST_LAST_NAME"
135-
+ " " + "CUST_CITY" + " " + "CUST_CREDIT_LIMIT");
132+
System.out.println(String.join(" ", "\nCUST_ID", "CUST_FIRST_NAME",
133+
"CUST_LAST_NAME", "CUST_CITY", "CUST_CREDIT_LIMIT"));
136134
System.out.println("-----------------------------------------------------------");
137135
while (resultSet.next()) {
138136
System.out.println(resultSet.getString(1) + " " + resultSet.getString(2) + " " +

0 commit comments

Comments
 (0)