大家来帮小弟我看一个错误,小弟我在PLSQL上连接数据库是没有有关问题。但是现在在JDBC中就出现有关问题了
大家来帮我看一个异常,我在PLSQL上连接数据库是没有问题。但是现在在JDBC中就出现问题了。
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:
172.16.23.76:1521:sensor_gmcc
------解决思路----------------------
jdbc连接数据库的三种格式:
格式一: Oracle JDBC Thin using a ServiceName:
jdbc:oracle:thin:@//<host>:<port>/<service_name>
Example: jdbc:oracle:thin:@//192.168.2.1:1521/XE
注意这里的格式,@后面有//, 这是与使用SID的主要区别。
这种格式是Oracle 推荐的格式,因为对于集群来说,每个节点的SID 是不一样的,但是SERVICE_NAME 确可以包含所有节点。
格式二: Oracle JDBC Thin using an SID:
jdbc:oracle:thin:@<host>:<port>:<SID>
Example: jdbc:oracle:thin:192.168.2.1:1521:X01A
Note: Support for SID is being phased out. Oracle recommends that users switch over to usingservice names.
格式三:Oracle JDBC Thin using a TNSName:
jdbc:oracle:thin:@<TNSName>
Example: jdbc:oracle:thin:@GL
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:
172.16.23.76:1521:sensor_gmcc
------解决思路----------------------
jdbc连接数据库的三种格式:
格式一: Oracle JDBC Thin using a ServiceName:
jdbc:oracle:thin:@//<host>:<port>/<service_name>
Example: jdbc:oracle:thin:@//192.168.2.1:1521/XE
注意这里的格式,@后面有//, 这是与使用SID的主要区别。
这种格式是Oracle 推荐的格式,因为对于集群来说,每个节点的SID 是不一样的,但是SERVICE_NAME 确可以包含所有节点。
格式二: Oracle JDBC Thin using an SID:
jdbc:oracle:thin:@<host>:<port>:<SID>
Example: jdbc:oracle:thin:192.168.2.1:1521:X01A
Note: Support for SID is being phased out. Oracle recommends that users switch over to usingservice names.
格式三:Oracle JDBC Thin using a TNSName:
jdbc:oracle:thin:@<TNSName>
Example: jdbc:oracle:thin:@GL