Oracle JDBC:用户名/密码无效 (ora-01017)
我在与 Oracle 数据库服务器的 jdbc 连接上遇到了一个奇怪的问题。
我们在 tomcat 服务器上运行应用程序。这些应用程序使用 oracle 数据库。所有应用程序都使用相同的凭据。
应用程序全天运行良好。晚上没有活动。早上,当应用程序尝试将自身重新连接到数据库时,我们会收到一些(2 或 3 个)ORA-01017(无效的用户名/密码)错误。
然后重新连接即可工作,应用程序将正常运行。
这可以持续几天(大约 5 天),然后阻止一个或多个应用程序!所有重新连接尝试都会失败。
我们跟踪了网络通信,发现如果连接失败,发送时会显示 ORA-01017 NO CREDENTIALS
。
当然,晚上没有人接触系统。
一种解决方法是,我们每天早上 6 点重新启动 tomcat 服务器,以清理每个连接缓存或池。这没有帮助。
怎么了?有什么想法吗?
持续 5 天出现完全阻塞的间隔(每天都重复)对我来说看起来很奇怪。
配置:
数据库Oracle 10.2、JDBC Driver 11.2 Thin、tomcat 6.0.24、JDK 6、操作系统为windows,部分应用程序为Dialogs for the Avaya Voice Portal 5.0。
我们自己的(非 VP)应用程序使用简单的连接(无池)。
该系统最初安装在 Windows 2003 服务器上,apserver 和 tomcat 服务器之间有 WAN。
现在系统已经迁移到数据库服务器附近的linux(CentOS)服务器上并且工作正常。不再有 ORA-01017。
I have a strange problem with jdbc connection to an oracle database server.
We've applications on a tomcat server running. These application use an oracle database. All applications use the same credentials.
Applications running fine the whole day. At night there is no activity. In the morning we get a few (2 or 3) ORA-01017 (invalid username/password) errors when the applications trying to reconnect themselves to the database.
Then reconnection works and the applications will operate normal.
This works for some days (around 5 days) and then one or more of the application block! All reconnection attempts fail.
We've traced network communication and found that if the connection fails with ORA-01017 NO CREDENTIALS
where sent.
Of course no one touches the system at night.
One attempt for a workaround is that we restart the tomcat server every morning at 6 o'clock to clean up every connection cache or pool. It does not help.
Whats wrong? Any ideas?
The continued 5 day interval in the appearance of a total blockage (while restating every day) looks very strange to me.
Config :
Database Oracle 10.2, JDBC Driver 11.2 thin, tomcat 6.0.24, JDK 6, OS is windows, some of the applications are Dialogs for the Avaya Voice Portal 5.0.
Our own (non VP) applications use simple Connections (no pooling).
The system was originally setup on a Windows 2003 server with a WAN between apserver and tomcat server.
The system is now migrated to a linux (CentOS) server near the database server and works fine. No ORA-01017 anymore.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如 Nikita Poberezkin 所说,我检查了 JDBC 驱动程序版本,发现它与我们的测试服务器不同。我删除了它并安装了相同版本的测试服务器,我想现在已经解决了。
As Nikita Poberezkin said, I checked my JDBC driver versions and saw it was different from our test server. I removed it and installed the same exact version of the test server and I guess it's solved now.
对我来说,不兼容的 OracleDriver 版本导致了这个问题。您的应用程序应该手动注册 oracle 驱动程序(我需要使用的 jar 正在执行),或者 agter java 6 ojdbc.jar 应该位于您的应用程序的类路径中。因此,谷歌为您的oracle安装兼容的驱动程序版本,然后在您的pom文件中声明它(使用所需的插件将其放入生成的jar中)并从代码中手动引用它,或者将ojdbc.jar放在您的jar可以看到它的地方有用的链接:
关于连接到oracle db: https://www.codejava.net/java-se/jdbc/connect-to-oracle-database-via-jdbc
关于 java 类路径:https://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
For me incompatible version of OracleDriver was causing this issue Your application should either register oracle driver manually (which jar that I needed to work with was doing) or agter java 6 ojdbc.jar should be in the classpath for your application. So google compatible driver version for your oracle installation and either declare it in your pom file (with needed plugin to put it in the resulting jar) and reference it manually from code or put the ojdbc.jar somewhere your jar can see it Usefull links:
About connecting to oracle db: https://www.codejava.net/java-se/jdbc/connect-to-oracle-database-via-jdbc
About java classpath: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
奇怪的。一些想法:
记录用户名和密码几天,以确保它们是正确的。代码中的某些错误可能会覆盖您不期望的值。
考虑将 JNDI 与 Tomcat 提供的连接池一起使用。 DBCP 有一些非常高级的选项来检查连接是否仍然存在以及如何重新连接。之后,您应该不会再在日志中看到任何与连接相关的问题。这也将提高安全性,因为应用程序不再需要知道数据库密码。
这可能是资源泄漏问题(如果应用程序从不返回连接,则会发生这种情况),但我希望出现不同的错误消息。
某些数据库(DB2、H2)允许创建视图,使其他数据库中的远程表像本地表一样可见。不确定 Oracle 是否支持此功能,但如果支持,则该远程表的用户名/密码可能是错误的。
另请考虑这篇博文中的要点: Oracle ORA-01017 提示
乍一看,没什么帖子中的内容可能会导致您出现问题,但也许某些脚本正在操纵 tnsnames.ora(例如分发新副本)。
或者 DBA 在每日备份期间禁用了所有用户。
Odd. Some ideas:
Log the user name and password for a few days just to make sure they are correct. Some bug in the code might overwrite a value that you don't expect.
Consider to use JNDI with a connection pool provided by Tomcat. DBCP has some really advanced options to check whether a connection is still alive and how to reconnect it. After that, you shouldn't see any connection related issues in your logs anymore. This would also improve security because none of the apps need to know the DB password anymore.
It might be a problem with resource leaks (happens if an app never returns the connection) but I'd expect a different error message, then.
Some databases (DB2, H2) allow to create views that make remote tables from other databases visible like local tables. Not sure whether Oracle supports this but if it does, then maybe the user name/password for this remote table is wrong.
Also consider the points in this blog post: Oracle ORA-01017 tips
At first glance, nothing in the post could cause your problems but maybe some script is manipulating the
tnsnames.ora
(for example distributing a new copy).Or the DBA disabled all users for the time of the daily backup.
我会检查 Oracle 侦听器和跟踪日志。正如 Aaron Digulla 所说,这听起来确实像是资源耗尽的情况。
I'd check Oracle listener and trace logs. As Aaron Digulla said, it does sound like some resource exhaustion.