【发布时间】:2014-04-28 02:37:14
【问题描述】:
我使用的是 Hibernate 3.3.1 和 jtds 1.2.2 作为 JDBC 驱动程序和 c3p0 版本 0.9.1.2 用于连接池以连接 SQL Server。
我的查询运行大约需要 12 秒。 当我运行查询时,我得到以下异常
ERROR [main] (JDBCExceptionReporter.java:101) - 无效状态,Connection 对象已关闭。 org.hibernate.exception.GenericJDBCException:无法检查 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.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:275) 在 org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:444) 在 org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1728) 在 org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) 在 org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
如果我修改查询以返回一小组数据,我不会得到异常。 好像配置有问题。
在我的 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
您能否建议需要设置哪些参数才能运行长时间运行的查询?
谢谢
【问题讨论】:
标签: java sql hibernate c3p0 jtds