我了解到要在hibernate中配置c3p0池,我们可以在hibernate.cfg.xml中编写配置如下:
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
Run Code Online (Sandbox Code Playgroud)
但是我使用Spring配置了Hibernate.当我尝试在下面做时,它将无法工作:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/news_loader" />
<property name="username" value="blah" />
<property name="password" value="blah" />
<property name="hibernate.c3p0.min_size" value="2" />
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.timeout" value="600" />
<property name="hibernate.c3p0.max_statements" value="0" />
<property name="hibernate.c3p0.idle_test_period" value="300"/>
<property name="hibernate.c3p0.acquire_increment" value="1" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我已经阅读过使用可以使用Spring配置的独立c3p0池,但有没有办法可以使用Spring在Hibernate中配置内置的c3p0池?
启发我因为我是初学者.
首先,在发布此问题之前,我已经阅读了与此错误相关的帖子。但是,大多数人不使用 PostgreSQL,因此此错误的处理方式可能有所不同。这是此错误的堆栈跟踪:
WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 08006
4450102501 [XmlBlaster.socket_ssl.cbWorkerThread] ERROR org.hibernate.util.JDBCExceptionReporter - An I/O error occured while sending to the backend.
java.lang.RuntimeException: org.hibernate.exception.JDBCConnectionException: could not execute query using iterate
at edu.umd.cattlab.vatraffic.listener.output.VaTrafficDbModule.processSingleMessage(VaTrafficDbModule.java:380)
at edu.umd.cattlab.vatraffic.listener.output.VaTrafficDbModule.processMessage(VaTrafficDbModule.java:266)
at edu.umd.cattlab.vatraffic.listener.input.InputModule.sendMessageToOuputModules(InputModule.java:36)
at edu.umd.cattlab.vatraffic.listener.input.XmlBlaster.update(XmlBlaster.java:173)
at org.xmlBlaster.client.XmlBlasterAccess.update(XmlBlasterAccess.java:1043)
at org.xmlBlaster.client.protocol.AbstractCallbackExtended.update(AbstractCallbackExtended.java:111)
at org.xmlBlaster.client.protocol.AbstractCallbackExtended.update(AbstractCallbackExtended.java:199)
at org.xmlBlaster.util.protocol.RequestReplyExecutor.receiveReply(RequestReplyExecutor.java:444)
at org.xmlBlaster.client.protocol.socket.WorkerThread.run(WorkerThread.java:51)
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query using iterate
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:427)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:380)
at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:224)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1192)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46)
at edu.umd.cattlab.schema.hibernate.cattXML.extensions.VaTraffic.VaTrafficHelper.laneMap(VaTrafficHelper.java:165)
at edu.umd.cattlab.vatraffic.listener.output.VaTrafficDbModule.processIncidentDescription(VaTrafficDbModule.java:396)
at edu.umd.cattlab.vatraffic.listener.output.VaTrafficDbModule.processSingleMessage(VaTrafficDbModule.java:360)
... …
Run Code Online (Sandbox Code Playgroud)