Advertisement
fkeles

withWallet.java

Jun 9th, 2023
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | Source Code | 0 0
  1.     public static void withWallet(String DB_USER, String DB_PASSWORD) {
  2.         System.setProperty("oracle.net.tns_admin", "C:/Users/FAKELES/Downloads/Wallet_PPWE68M5DV8YENWC/");
  3.         //Can be also set by command line
  4.         //-Doracle.net.tns_admin=C:/Users/FAKELES/Downloads/Wallet_PPWE68M5DV8YENWC/
  5.        
  6.         String JDBC_URL = "jdbc:oracle:thin:@ppwe68m5dv8yenwc_high";
  7.         //JDBC_URL can be in different forms containing TNS_ADMIN
  8.         //1. jdbc:oracle:thin:@ppwe68m5dv8yenwc_high?TNS_ADMIN=C:/Users/FAKELES/Downloads/Wallet_L9XC7P0J0B9UJOMY/
  9.         //2. jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.uk-london-1.oraclecloud.com))(connect_data=(service_name=gf5f9ffc50769d0_ppwe68m5dv8yenwc_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))?TNS_ADMIN=C:/Users/FAKELES/Downloads/Wallet_L9XC7P0J0B9UJOMY/
  10.        
  11.         String SQL = "SELECT * FROM v$pdbs";
  12.         Connection c = null;
  13.         PreparedStatement ps = null;
  14.         ResultSet rs = null;
  15.         try {
  16.             c = DriverManager.getConnection(JDBC_URL, DB_USER, DB_PASSWORD);
  17.             ps = c.prepareStatement(SQL);
  18.             rs = ps.executeQuery();
  19.             rs.next();
  20.             System.out.println(rs.getString("cloud_identity"));
  21.         } catch (SQLException ex) {
  22.             Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
  23.         } finally {
  24.             try{rs.close();}catch(SQLException e){;}
  25.             try{ps.close();}catch(SQLException e){;}
  26.             try{c.close();}catch(SQLException e){;}
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement