当前位置: 首页 > 知识库问答 >
问题:

Android-Oracle 12c数据库连接问题:java.sql.sqlexception:ORA-28040:没有匹配的身份验证协议

苏富
2023-03-14

最近三天以来,我遇到的问题只是简单的连接Android-Oracle12c数据库。

最近我上传了Android-Oracle-Connection,但它的11G版本。我使用过ojdbc14.jar

/**
 * 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);
}
java.sql.SQLException: ORA-28040: No matching authentication protocol
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)

我也试过这个答案,但得到的错误是:

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)

我没有找到任何教程或文档来连接12C。有人能帮忙吗?

共有1个答案

查学文
2023-03-14

但是仅仅为了回答它,您必须在数据库服务器sqlnet.ora文件上添加一个参数,以允许从较旧的客户端进行连接。当您的客户端是旧的并且服务器只允许从最新版本的sqlnet客户端进行连接时,就会发生此错误。示例11g客户端尝试连接到18c DB服务器。

 类似资料: