简体   繁体   中英

Java Connection String to Oracle Cloud Database

I had problem when connecting to Oracle Cloud Database from java code.

  • I have no problem connecting other non-cloud oracle databases.

  • I can connect to the Oracle Cloud Database with sql tools, except from the java codes.

  • The hostname, username and password is correct one, i don't reveal the real username and password.

Error: java.sql.SQLException:

SQLException: SQLState(null) vendor code(17002)
java.sql.SQLException: Io exception: Oracle Error ORA-12650: No common encryption or data integrity algorithm

My code as following:

String dbURL = "jdbc:oracle:thin:@192.133.133.23:1521:ORCL";

try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection(dbURL, "username1", "password");


}catch(Exception)
{
  e.printStacktrace();
}
/**
 * The below one is for oracle thin client
   Its worked for the ojdbc6 driver. 
 */
public Connection conCheck() {

      Connection con=null;
      try { //step1 load the driver class
      Class.forName("oracle.jdbc.OracleDriver");

      Properties props = new Properties();
      props.put("oracle.net.encryption_client", "REQUIRED");
      props.put("oracle.net.encryption_types_client",  "( " + AnoServices.ENCRYPTION_AES256 + "," +AnoServices.ENCRYPTION_AES192 + ")");
      props.put("oracle.net.crypto_checksum_types_client", "( SHA1 )");
      props.put("user", "username");
      props.put("password","password");

    //step2 create  the connection object          
      con=DriverManager.getConnection(  "jdbc:oracle:thin:@host:port:serveiceid",props);

       System.out.println("Con"+con);
      }catch(Exception e) {e.printStackTrace(); }       

 return con;
}

Seems like changing syntax in your connection string to lookup SERVICE_NAME instead of SID must help you connect your database.

String dbURL = "jdbc:oracle:thin:@192.133.133.23:1521/ORCL";

Additional Read : Thin-style Service Name Syntax

If this as well doesn't help, then would suggest to add below 2 lines to your sqlnet.ora in database.

SQLNET.CRYPTO_CHECKSUM_TYPES_CLIENT= (SHA1)
SQLNET.CRYPTO_CHECKSUM_CLIENT = requested

First mandatory check is to verify the oracle jdbc version. if you use incompatible version,we will get this kid of errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM