处理Oracle报错:ORA-01005: null password given; logon denied【测试成功】

艺帆风顺 发布于 2025-04-02 17 次阅读


ORA-01005: null password given; logon denied

最近在测试JDBC连接Oracle数据库兼容密码包含特殊字符的问题时,出现了java.sql.SQLException: ORA-01005: null password given; logon denied的报错,尝试了各种Debug调试,确认程序完全没有问题,在本机测试也没问题,数据库驱动(官网下载的对应数据库版本的驱动)和JDK版本(都是Oracle JDK 1.8)两边环境也一样,但部署到应用环境上就是报错,翻遍了各种帖子也没解决,最后偶然看到了一个回复,尝试了下果然好了

具体报错信息如下:

    java.sql.SQLException: ORA-01005null password given; logon denied        at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:628)        at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:557)        at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:552)        at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:1312)        at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:699)        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:726)        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:291)        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:389)        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTHWithO5Logon(T4CTTIoauthenticate.java:1455)        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:1219)        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:1173)        at oracle.jdbc.driver.T4CConnection.authenticateUserForLogon(T4CConnection.java:1030)        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:646)        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:1032)        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:90)        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:681)        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:602)        at java.sql.DriverManager.getConnection(DriverManager.java:664)        at java.sql.DriverManager.getConnection(DriverManager.java:247)        at com.adtec.moia.control.agent.util.MoiaUtil.getConnection(MoiaUtil.java:195)        at com.adtec.moia.control.agent.deal.dbsjob.DbsJobExecutor.execute(DbsJobExecutor.java:70)        at com.adtec.moia.control.agent.deal.JobExecuteThread.run(JobExecuteThread.java:99)        at java.lang.Thread.run(Thread.java:748)        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)        at java.lang.Thread.run(Thread.java:748)

    最后在Bing国际版的搜索中找到了下面的参考信息:

    意思就是让换下驱动尝试下

    java.sql.SQLException: ORA-01005: null password given; logon denied - Java - JDBC Archive (databaseusers.com)

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

      Hello! I'm getting this exception while trying to establish a JDBC connection to an Oracle database (10g Express Edition): java.sql.SQLException: ORA-01005: null password given; logon denied The code is the following:try { OracleDataSource ods = new OracleDataSource(); ods.setDriverType("thin"); ods.setPassword("rafael"); ods.setUser("rafael"); ods.setDatabaseName("XE"); ods.setPortNumber(1521); ods.setServerName("iceman"); Connection c = ods.getConnection(); } catch (SQLException e) { e.printStackTrace(); }I'm also getting the same exception while running this code:Connection c = DriverManager.getConnection("jdbc:oracle:thin:#iceman:1521:XE""rafael""rafael");An interesting fact is DbVisualizer is successfully connecting to this database using exactly the above url. You can see the screen captured here: http://db.tt/YKxQCvf Anyone can help me to bypass this problem? Thanks in advance Edited by: user13275297 on 22/06/2011 13:14This could be the jar issue, post the jdk version and jar you are using to establish the db connection.if you are not using ojdbc14.jar, then you can make a try with this jar.also go through the below post, it might help you:Login failure using Oracle Express 10.2, Java 6 and ojdbc5/6 11.x

      最终解决:

      已经黔驴技穷的情况下就尝试下,又下载了一个低版本的数据库驱动,替换了原装驱动,JDK没有动,再验证通过了…

      根本原因还是没有太明白,也有可能是JDK版本和数据库驱动兼容性的问题,但解决方案就是这样,尝试换下不同版本的驱动

      PS:

      我的数据库版本是19c,当时驱动是直接使用的数据库服务器下的这个驱动$ORACLE_HOME/jdbc/lib/ojdbc8.jar

      后面也怀疑是驱动问题,就从官网上下载了对应版本的驱动,但还是报错,就是这块走进了小黑屋,就没再想驱动的问题

      最后解决了问题后,在这个目录下./dmu/jlib/ojdbc8.jar也发现了还有一个ojdbc8.jar驱动,和后来下载的低版本驱动一致,尝试使用了下一切正常

      所以,如果遇到这样的报错,在确定代码无问题的情况下,还是需要从驱动出发进行解决…

        版权声明:本文内容来自CSDN:黑伴白,遵循CC 4.0 BY-SA版权协议上原文接及本声明。本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行可。原文链接:https://blog.csdn.net/weixin_49192027/article/details/122357073如有涉及到侵权,请联系,将立即予以删除处理。在此特别鸣谢原作者的创作。此篇文章的所有版权归原作者所有,与本公众号无关,商业转载建议请联系原作者,非商业转载请注明出处。