Chinaunix首页 | 论坛 | 博客
  • 博客访问: 339718
  • 博文数量: 72
  • 博客积分: 1908
  • 博客等级: 上尉
  • 技术积分: 900
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-06 23:13
文章分类

全部博文(72)

文章存档

2013年(2)

2012年(10)

2011年(36)

2010年(8)

2009年(12)

2007年(4)

我的朋友

分类: Oracle

2007-11-23 13:58:40

作者: 发表于:8:56 am. 星期二, 11月 20th, 2007
:可以任意转载,转载时请务必以超链接形式标明文章和作者信息及。

数据库升级为Oracle 10g RAC,原有的连接方式下,出现如下错误:

出错信息:
- Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: “o
rg.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFacto
ry (Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(
ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))))”
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnect
ion(QueryTagSupport.java:276)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag
(QueryTagSupport.java:159)

于是根据网上的资料修改了JDBC的URL,正确jdbc的url为:

jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.103)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.104)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = mydb.618119.com) ) )

或者:

jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = db01.618119.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)
(HOST = db02.618119.com)(PORT = 1521))
(LOAD_BALANCE = yes)
(failover = yes)
(CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = mydb.618119.com) ) )

结果过依然存在问题:

偶尔会出现错误:

An error occurred while establishing the connection:
Type: java.sql.SQLException Error Code: 17002
Message:
Io 异常: Connection refused(DESCRIPTION=(ERR=1153)(VSNNUM=169869568)(ERROR_STACK=(ERROR=(CODE=1153)(EMFI=4)(ARGS=’(ADDRESS=(PROTOCOL=TCP)(HOST=RAC02)(PORT=1521))’))(ERROR=(CODE=305)(EMFI=1))))

试了将驱动替换为10g的ojdbc14.jar.

然后再在DbVisualizer中试了很多次断开连接和重新链接,都还没出错.
但是在web页面中测试,还是经常出现获取不到数据库连接的情况.

在网上查询了很多资料,仍未能解决这个问题, 不得已,只好换成oci方式连接.
在jdbc客户端所在地服务器中,将TNSNAMES.ORA里本地服务名配置为
mydb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.103)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.40.104)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mydb.618119.com)
)
)

oci方式的jdbc url=”jdbc:oracle:oci:@mydb”;

获取数据库连接正常.

0.229.9.5_ODS1 =
  (description =
    (enable = broken)
    (address = (protocol = tcp)(host = 10.229.9.5)(port = 1521))
    (connect_data =
      (service_name = ods)
      (instance_name = ods1)
      (failover_mode =
        (backup = ods2)
        (TYPE = session)
        (METHOD = basic)
        (RETRIES = 400)
        (DELAY = 10)
      )
    )
  )

阅读(2925) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~