首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为长时间运行的查询设置c3p0配置

为长时间运行的查询设置c3p0配置
EN

Stack Overflow用户
提问于 2014-03-21 06:42:08
回答 1查看 1.7K关注 0票数 0

我使用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文件中,我有以下配置值

代码语言:javascript
复制
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

您能建议一下运行长时间运行的查询需要设置哪些参数吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2014-03-21 08:11:56

对于长时间运行的查询,c3p0不需要特殊的设置,尽管有一些设置(特别是unreturnedConnectionTimeout)可能会干扰长时间运行的查询。

我会验证是否未设置unreturnedConnectionTimeout。(可以在hibernate.properties文件之外的很多地方设置c3p0配置。)c3p0转储其配置以记录池初始化时的信息。查找unreturnedConnectionTimeout的值。它应该是0。

如果该值为0,则在c3p0级别上没有任何东西会干扰您的长持续时间查询。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22546711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档