oracle只能连接orcl库,无论程序里指定什么库名
使用plsqldeveloper:
scott,tiger连接GAOCONG库可以成功。
java程序语句:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:localhost:1521:GAOCONG", "scott", "tiger");
程序连接报错:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl
主要问题:无论在程序里指定什么库名,程序就要去连接orcl库。我本机没有orcl库。自从拿了别人一个项目运行后就出现了这个问题,至今没有解决,请教各位了,谢谢。
[最优解释]
DriverManager.getConnection("jdbc:oracle:thin:localhost:1521:GAOCONG",
改成
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:GAOCONG",
[其他解释]
配置的localhost你觉得有问题吗???
Rayn412552703
[其他解释]
你的数据的名字就叫GAOCONG吗?
Rayn412552703
[其他解释]