运行websphere过程出现以下jdbc出错

05-03-28 jjx333

我使用Hibernate开发一个程序,运行在Websphere上,发现如果间隔一断时间,大约1H,就会出现以下的问题

[05-3-25 12:42:45:848 CST] 1d4db1a7 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 17002, SQLState: null

[05-3-25 12:42:46:020 CST] 1d4db1a7 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter Io 异常: Connection reset by peer: socket closed

[05-3-25 12:42:46:036 CST] 1d4db1a7 JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 17002, SQLState: null

[05-3-25 12:42:46:052 CST] 1d4db1a7 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter Io 异常: Connection reset by peer: socket closed

[05-3-25 12:42:46:067 CST] 1d4db1a7 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter Could not execute query

[05-3-25 12:42:46:114 CST] 1d4db1a7 JDBCException E net.sf.hibernate.util.JDBCExceptionReporter TRAS0014I: 下列异常已记录 java.sql.SQLException: Io 异常: Connection reset by peer: socket closed

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)

at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:503)

at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:518)

at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:210)

at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:193)

at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:869)

at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:704)

at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:249)

at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:223)

at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)

at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.doList(Loader.java:955)

at net.sf.hibernate.loader.Loader.list(Loader.java:946)

at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)

at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)

at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)

at com.hnyl.sh.posa.dao.distributework.UserInfoDao.getUserInfo(UserInfoDao.java:87)

at com.hnyl.sh.posa.login.LoginAction.execute(LoginAction.java:39)

at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)

我想是否。连接池断了或连接池超时,是这些问题如何解决 !

谢谢

banq
2005-03-28 10:29

用用webshere的dataSource试验看看,不要直接使用Hibernate的连接池。

jjx333
2005-03-28 10:43

之后我把hibernate.cfg.xml

改成

<hibernate-configuration>

<session-factory>

<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>

<property name="connection.datasource">jdbc/posa</property>

<!--

<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

<property name="connection.username">posa</property>

<property name="connection.password">sh1bm2</property>

<property name="connection.url">jdbc:oracle:thin:@iftis:1521:mjettdb</property>

-->

<property name="connection.pool.size">30</property>

<property name="statement_cache.size">25</property>

<property name="jdbc.fetch_size">50</property>

<property name="jdbc.batch_size">25</property>

<property name="show_sql">true</property>

<!-- Mapping files -->

<mapping resource="com/hnyl/sh/posa/po/posa.hbm.xml"/>

<mapping resource="com/hnyl/sh/posa/entity/posa.hbm.xml"/>

</session-factory>

</hibernate-configuration>

我使用了

<property name="connection.datasource">jdbc/posa</property>

是用websphere的连接的

可是好像还是报这个错误呀!

zjsun
2005-03-28 20:50

WebSphere数据源连接池大小、数据源连接物理时间以及Oracle数据库的会话时间三者参数需要调整到相互匹配

DataSource将保持连接池最小值个数的Connection常连接,如果在WAS的数据源连接超时之前,Oracle数据库段的会话Timeout了,就有可能出现这种情况。

这些参数没有一个推荐值,需要不停的作试验,以达到最佳性能效果。

你可以尝试如下操作:

1、适当调小连接池的最小数

2、适当调小数据源连接超时时间(这是应用服务器主动释放物理连接的时间)

3、适当调大Oracle会话时间

需要说明的是以上任意一个参数的调整都有可能是性能的瓶颈,需要通过大量的试验。

jjx333
2005-03-30 13:56

我调整了websphere

的jdbc 连接池

不使用超时=0

可是发现过一断时间,还是报同样的错误!