gpt4 book ai didi

java - JDBC连接异常

转载 作者:行者123 更新时间:2023-12-01 14:26:24 25 4
gpt4 key购买 nike

我收到异常 ORA-12504,TNS:监听器未在 CONNECT_DATA 中给出 SID你能帮我解决这个问题吗?tnsnames.ora

SUNRISEDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = SUNRISEDB)
)
)

listener.ora

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = pacdcinfoddpodbc.cable.comcast.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)

ADR_BASE_LISTENER = C:\app\kkumar003c

我的java代码是

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521","KIRANDB","KIRANDB");
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("db connection=="+dbConn);
}

最佳答案

更改此行 -

dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521","KIRANDB","KIRANDB");

dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521:**SUNRISEDB**","KIRANDB","KIRANDB");

关于java - JDBC连接异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17152437/

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