gpt4 book ai didi

oracle - 从 Java 连接到 Oracle DB 时出错

转载 作者:行者123 更新时间:2023-12-03 00:06:08 26 4
gpt4 key购买 nike

有人可以帮助我解释为什么我在尝试从 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:oracle:thin:@winson.net:1522:hcrod

确实没有 // 和 : 而不是 /

关于oracle - 从 Java 连接到 Oracle DB 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8104133/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com