我收到异常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);
}
答案 0 :(得分:1)
更改此行 -
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");
答案 1 :(得分:0)
您需要使用您的架构名称代替 NAME 。
dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521:NAME","KIRANDB","KIRANDB");