gpt4 book ai didi

java - 如何解决 oracle 11g jdbc 7/14 jdk 1.7 中的读取调用减一?

转载 作者:行者123 更新时间:2023-11-30 08:48:53 26 4
gpt4 key购买 nike

我正在使用 netbeans 和 jdk 7 updt 9 以及 1.7,以下是我的代码。

public class jd {
public static void main(String[] args) throws ClassNotFoundException, SQLException
{

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1158:ORCL","system", "system");
System.out.println("Connection successful");
// Statement s = con.createStatement();

}

}

输出是

 run:
Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at jd.main(jd.java:22)
Caused by: oracle.net.ns.NetException: Got minus one from a read call
at oracle.net.ns.Packet.receive(Packet.java:314)
at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:153)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
... 7 more

Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

最佳答案

DriverManager 在尝试使用无效 URL 建立连接时抛出此错误。确保您的网址有效。要结账的东西:

  1. 端口:Oracle db 在 1521 上运行。(注意:不要将自己与 oracle 的 webport 混淆,它可以是您的 URL 1158 中的任何其他端口)。
  2. 数据库名称:从 Oracle Web UI 获取数据库名称:(home->adminIstration->aboutdatabase->settings)
  3. URL 格式:"jdbc:oracle:thin:@localhost:1521:YourDbName"

关于java - 如何解决 oracle 11g jdbc 7/14 jdk 1.7 中的读取调用减一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31704622/

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