hades
hades

Reputation: 4696

Java Connection String to Oracle Cloud Database

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

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();
}

Upvotes: 1

Views: 3645

Answers (3)

Bibin Raj
Bibin Raj

Reputation: 79

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

Upvotes: 0

Saiprasad Bane
Saiprasad Bane

Reputation: 487

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

Upvotes: 0

Bibin Raj
Bibin Raj

Reputation: 79

/**
 * 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;
}

Upvotes: 1

Related Questions