从Java连接到Oracle DB时出错

前端之家收集整理的这篇文章主要介绍了从Java连接到Oracle DB时出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有人可以帮我解释为什么我在尝试从 java连接到Oracle数据库时收到以下错误….

连接呼叫是:

Connection con = DriverManager.getConnection(
     "jdbc:oracle:thin:@winson.net:1522/hcrod","manager","passing");

我收到以下错误

java.sql.sqlException: Listener refused the connection with the following error:
ORA-12514,TNS:listener does not currently know of service requested in connect descriptor
at oracle.jdbc.driver.DatabaseError.throwsqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwsqlException(DatabaseError.java:263)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at test_sample.main(test_sample.java:15)

解决方法

在类似的情况下,我工作了一个稍微的其他连接字符串:
JDBC:神谕:薄:@ winson.net:1522:hcrod

真的没有//和with:而不是/

原文链接:https://www.f2er.com/java/239891.html

猜你在找的Java相关文章