简体   繁体   中英

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

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.

Could you tell me how to fix this problem ? thanks

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

By removing this one, everything goes well.

This post solved my problem

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

ORA-01017 when connecting through jdbc thin driver

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

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

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

In my case, (where all the jars, including ojdbc8 is in the folder ./libs), I change from

java -Djava.ext.dir=libs/ MainClass

to

java -cp "./libs/*" MainClass

Then the problem is gone.

I had faced the same problem with spring boot app when externalized all the jars. The java.ext.dirs doesn't work with oracle driver 19.x, throws "java.sql.SQLException: ORA-01005: null password given; logon denied". The application worked fine with fat-jar.

I was able to resolve the issue with "export CLASSPATH".

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