ORA-01005: null password given; logon denied

本文遵循BY-SA版权协议,转载请附上原文出处链接。


本文作者: 黑伴白

本文链接: http://heibanbai.com.cn/posts/ecfb9d68/

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)两边环境也一样,但部署到应用环境上就是报错,翻遍了各种帖子也没解决,最后偶然看到了一个回复,尝试了下果然好了

具体报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
java.sql.SQLException: ORA-01005: null 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

1
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:14
1
2
3
4
This 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驱动,和后来下载的低版本驱动一致,尝试使用了下一切正常

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


蚂蚁再小也是肉🥩!


ORA-01005: null password given; logon denied
http://heibanbai.com.cn/posts/ecfb9d68/
作者
黑伴白
发布于
2022年1月8日
许可协议

“您的支持,我的动力!觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付