JDBC thin连接oracle的一种方法:
String dbUrl = "jdbc:oracle:thin:@"+dbIP+":"+1521+":"+SID;这里的SID并不是在tnsnames.ora中的SERVICE_NAME,而是数据库的SID,查询SID的语句如下:
select instance_name from v$instance;
输入错误的SID会报错:
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