Hibernate SQL错误:17002,SQLState:空Io异常:连接重置

Hibernate SQL错误:17002,SQLState:空Io异常:连接重置,hibernate,connection-pooling,c3p0,Hibernate,Connection Pooling,C3p0,我们正在使用Hibernate3和c3p0-0.9.1。我们有一个基于Hibernate标准的查询来检查数据库表中键入的用户名和密码以及其他查询。在执行第一个查询(即登录页面)的过程中,我们面临连接重置问题,SQLState为null。如果在页面中再次提供详细信息,则在一段时间内,一切正常。如果我们尝试一段时间后,再次相同的问题,第一次和重新输入用户名和密码时,它是正常工作了一段时间。请查找以下错误消息以供参考 00:12:42警告[org.hibernate.util.jdbceptionRe

我们正在使用Hibernate3和c3p0-0.9.1。我们有一个基于Hibernate标准的查询来检查数据库表中键入的用户名和密码以及其他查询。在执行第一个查询(即登录页面)的过程中,我们面临连接重置问题,SQLState为null。如果在页面中再次提供详细信息,则在一段时间内,一切正常。如果我们尝试一段时间后,再次相同的问题,第一次和重新输入用户名和密码时,它是正常工作了一段时间。请查找以下错误消息以供参考

00:12:42警告[org.hibernate.util.jdbceptionReporter:77 logExceptions]-SQL错误:17002,SQLState:null 00:12:42错误[org.hibernate.util.jdbceptionReporter:78 logExceptions]-Io异常:连接重置

下面是示例代码

public UserSample fetchUserDetails(final String loginId) throws DataAccessException {    
       return (UserSample) getHibernateTemplate().execute(new HibernateCallback() {
            public Object doInHibernate(Session session)
                    throws HibernateException, SQLException {

                Criteria criteria = getSession().createCriteria(UserSample.class)
                    .createAlias("rolesample", "rolesample")
                    .createAlias("accountsample", "accountsample");
                try {
                    if(loginId!= null){
                        criteria.add(Restrictions.eq("loginName",loginId));
                    }

            criteria.setProjection(Projections.projectionList()
                .add(Projections.property("loginName").as("loginName2"))
                .add(Projections.property("password").as("password"))
                .add(Projections.property("name").as("name"))
                .add(Projections.property("roleId").as("roleId"))               );

                criteria.addOrder(Order.desc("loginName"));
                criteria.setFetchSize(1);
                criteria.setMaxResults(1);
                criteria.setResultTransformer(Transformers.aliasToBean(UserSample.class));

                ArrayList list = (ArrayList)criteria.list();
                if(list != null && list.size() > 0) {
                    return  (User)criteria.list().get(0);
                }else{
                    return new User();
                }
            }
                catch (Exception e) {
                    LogUtil.info(e.getMessage());
                    return null;
                }
            }
        }); 
   }
applicationContext.xml中的连接池如下所示:

<bean id="sampleSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="sampleDataSource" />

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
                <prop key="hibernate.connection.pool_size">50</prop>
                <prop key="hibernate.show_sql">false</prop>                
                <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>                

                <!-- C3P0 Properties -->
                <prop key="hibernate.c3p0.min_size">3</prop>
                <prop key="hibernate.c3p0.max_size">50</prop>
                <prop key="hibernate.c3p0.timeout">1800</prop>
                <prop key="hibernate.c3p0.max_statements">100</prop>
                <prop key="hibernate.c3p0.idle_test_period">600</prop>
                <prop key="hibernate.c3p0.acquire_increment">1</prop>
                <prop key="hibernate.c3p0.preferredTestQuery">SELECT 1 FROM DUAL</prop>
            </props>            
        </property>

org.hibernate.dialen.oraclealent
真1,假0,是“Y”,否“N”
50
假的
org.hibernate.connection.C3P0ConnectionProvider
3.
50
1800
100
600
1.
从双重选择中选择1
当我在oracle客户端(如SQL deverOper)中执行生成的查询时,我能够得到结果。但是,在应用程序中运行时,会随机面对此问题。你能帮忙吗?谢谢

致以最良好的祝愿,
Lucky

您必须提供更多详细信息才能对此进行故障排除

  • 您正在连接到哪个数据库
  • 粘贴hibernate查询执行代码
  • 连接重置错误是由于

    当远程连接意外断开且 由于应用程序崩溃等各种原因而强制关闭, 系统重新启动,远程主机硬关闭。来自远程的内核 系统向本地系统发送带有RST位的数据包。当地人 执行任何发送时的套接字(可以是保持活动的数据包)或 接收操作随后失败,并出现此错误。某些 延迟设置的组合也可能导致数据包具有RST 位设置

    为了帮助调试,您可以使用工具查看实际的网络数据包