oracle java.sql.SQLException: ORA-01005: 给出空密码;登录被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38609280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:16:31  来源:igfitidea点击:

java.sql.SQLException: ORA-01005: null password given; logon denied

javasqloracledatabase-connectionaix

提问by kkung

I'm getting the follwing exception while trying to connect to a database:

尝试连接到数据库时出现以下异常:

java.sql.SQLException: ORA-01005: null password given; logon denied
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:385)
        at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:938)
        at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:480)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:416)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:825)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:596)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
        at java.sql.DriverManager.getConnection(DriverManager.java:675)
        at java.sql.DriverManager.getConnection(DriverManager.java:258)
        at com.alting.db.ManagerDB.getConnection(ManagerDB.java:57)
        at com.alting.db.ManagerDB.openConnection(ManagerDB.java:75)
        at com.alting.med.EventGenerator.exportData(EventGenerator.java:220)
        at com.alting.med.Main.main(Main.java:252)

here the method used to get the connection:

这里用于获取连接的方法:

private Connection getConnection(String url, String driverClass, String user, String password) throws ManagerDBException 
{
    try
    {
        Class.forName(driverClass);
    } catch (ClassNotFoundException e) {
        throw new ManagerDBException(e.getMessage());
    }

    try
    {
      this.connection = DriverManager.getConnection(url, user, password);
    }
    catch (SQLException e)
    {
      throw new ManagerDBException(e.getMessage());
    }
    return this.connection;
}

But even when the params (url, password..) are hardcoded, I still get the exception.

但即使参数(url、密码..)是硬编码的,我仍然得到异常。

Could you tell me how to fix this problem ? thanks

你能告诉我如何解决这个问题吗?谢谢

采纳答案by kkung

it appears the problem is linked to the "-Djava.endorsed.dirs" parameter from the java startup command line.

问题似乎与 java 启动命令行中的“-Djava.endorsed.dirs”参数有关。

By removing this one, everything goes well.

通过删除这个,一切顺利。

回答by ixi

This post solved my problem

这个帖子解决了我的问题

java.sql.SQLException: ORA-01005: null password given; logon denied

java.sql.SQLException: ORA-01005: 给出空密码;登录被拒绝

ORA-01017 when connecting through jdbc thin driver

通过 jdbc 瘦驱动程序连接时出现 ORA-01017

Added -Doracle.jdbc.thinLogonCapability=o3parameter to the java startup line.

-Doracle.jdbc.thinLogonCapability=o3向 java 启动行添加了参数。

回答by teoreda

If you use an empty string password Oracle JDBC will consider that equivalent to NULL.

如果您使用空字符串密码 Oracle JDBC 会认为它等同于NULL

回答by Jean de Lavarene

I've seen this error when using JDK6 and it went away when switching to JDK8 (use the latest version of JDK8).

我在使用 JDK6 时看到过这个错误,在切换到 JDK8 时它消失了(使用最新版本的 JDK8)。