用jdbc连接oracle10g需要注意事项

用jdbc连接oracle10g需要注意事项

 今天用数据池配置数据源,发现抛出异常
Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153093120)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
Driver Classname: oracle.jdbc.driver.OracleDriver
URL:jdbc:oracle:thin:@145.32.16.1:1521:zzlt
解决办法:9i和10g的驱动不要混了,要一一对应

换了以后还是不行抛出异常
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.21.18.78:1521:usky
解决办法:
10.1.0.2.0有这个问题,必须用机器名连接,不能用IP地址。把Listener.ora文件中的监听配置成IP地址也行。10.1.0.3.0就没有这个问题了。另外安装时Listener.ora是默认安装需改成
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = d:\oracle\product\10.2.0\db_1)
      (GLOBAL_DBNAME = orcl)
      (PROGRAM = extproc)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = toby)(PORT = 1521))
    )
  )

改完后需重启服务,到晚上1点才解决。以上为分经验分享。

你可能感兴趣的:(用jdbc连接oracle10g需要注意事项)