Android – Oracle 12c Database Connection Issue : java.sql.SQLException: ORA-28040: No matching authentication protocol-ThrowExceptions

Exception or error:

Since last 3 days I am getting problem with just simple connection of Android – Oracle 12c Database.

Recently I have uploaded Android-Oracle-Connection but its for 11g version. I have used ojdbc14.jar

I have used following lines of code in that demo:

/**
 * Driver for Oracle
 */
private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";


/**
 * URL to connect database
 */
private static final String DEFAULT_URL = "jdbc:oracle:thin:@192.168.0.102:1521:oracle"; // Change IP_Address:Database

/**
 * Creating Connection
 *
 * @param driver   driver object
 * @param url      url for db
 * @param username username
 * @param password password
 * @return Connection object
 * @throws ClassNotFoundException throwing exception
 * @throws SQLException           throwing exception
 */
public static Connection createConnection(String driver, String url, String username, String password) throws ClassNotFoundException, SQLException {
    Class.forName(driver);
    return DriverManager.getConnection(url, username, password);
}

Now Problem is, I am using IP : 192.168.0.102 for 11g which was successfully connected but I have change IP 192.168.0.105 for 12c with same code but its not working.

I am getting error as:

java.sql.SQLException: ORA-28040: No matching authentication protocol

I have already checked this answer and tried but getting error as:

W/oracle.jdbc: Error while registering Oracle JDBC Diagnosability MBean.
    java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;
        at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:321)
        at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:203)
        at java.security.AccessController.doPrivileged(AccessController.java:43)
        at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:199)
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at java.lang.Class.forName(Class.java:379)

I have already tried this answer too but getting error as:

2019-11-23 16:36:12.564 28567-28567/com.demo.oracle E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.demo.oracle, PID: 28567
    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
        at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:230)
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at java.lang.Class.forName(Class.java:379)

I didn’t found any tutorial or documentation to connect with 12c. Can anyone help?

How to solve:

Old post but just to answer it, you have to add a parameter on the Database Server sqlnet.ora file to allow connection from older clients. This error happens when your client is old and server is only allows connection from recent version of sqlnet client. Example 11g client trying to connect to 18c DB Server.

Leave a Reply

Your email address will not be published. Required fields are marked *