我使用Hibernate版本3.3.1和jtds 1.2.2作为JDBC驱动程序,使用c3p0版本0.9.1.2作为连接池来连接SQL Server。
我的查询大约需要12秒才能运行。当我运行查询时,我得到了以下异常
错误main -状态无效,连接对象已关闭。JDBC :无法在org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)、org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)、org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)、org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)、org.hibernate.exception.GenericJDBCException、org.hibernate.impl.SessionImpl检查JDBC自动提交模式。org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1728) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)的afterOperation(SessionImpl.java:444)
如果我修改查询以返回一小部分数据,我不会得到异常。似乎有一些配置问题。
在我的hibernate.properties文件中,我有以下配置值
hibernate.format_sql=true
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.optimistic-lock=true
hibernate.connection.autocommit=true
hibernate.show_sql=false
hibernate.generate_statistics=false
c3p0.acquire_increment=1
c3p0.idle_test_period=1000
c3p0.max_size=10
c3p0.max_statements=0
c3p0.min_size=5
c3p0.timeout=800您能建议一下运行长时间运行的查询需要设置哪些参数吗?
谢谢
发布于 2014-03-21 08:11:56
对于长时间运行的查询,c3p0不需要特殊的设置,尽管有一些设置(特别是unreturnedConnectionTimeout)可能会干扰长时间运行的查询。
我会验证是否未设置unreturnedConnectionTimeout。(可以在hibernate.properties文件之外的很多地方设置c3p0配置。)c3p0转储其配置以记录池初始化时的信息。查找unreturnedConnectionTimeout的值。它应该是0。
如果该值为0,则在c3p0级别上没有任何东西会干扰您的长持续时间查询。
https://stackoverflow.com/questions/22546711
复制相似问题