0

我们正在使用数据库组件中的 mule 提供的连接池。当我们施加巨大的负载时,我们正在低于错误。

配置参数为:maxConnection=100, minConn=0, autoIncrement =15 waitMillisec=10000 并且准备好的语句缓存大小保持默认(即没有配置任何东西)。您能否在下面帮助解决这个问题。

{"timestamp":"2016-10-22T09:28:13,611","level":"WARN","thread":"ActiveMQ Session Task-25","loggerName":"com.mchange.v2.c3p0.impl.NewPooledConnection","message":"[c3p0] A PooledConnection that has already signalled a Connection error is still in use!"}    
{"timestamp":"2016-10-22T09:28:13,611","level":"WARN","thread":"ActiveMQ Session Task-25","loggerName":"com.mchange.v2.c3p0.impl.NewPooledConnection","message":"[c3p0] Another error has occurred [ java.sql.SQLException: A problem occurred while trying to acquire a cached PreparedStatement in a background thread. ] which will not be reported to listeners!"}
    java.sql.SQLException: A problem occurred while trying to acquire a cached PreparedStatement in a background thread.
        at com.mchange.v2.c3p0.stmt.GooGooStatementCache.acquireStatement(GooGooStatementCache.java:571) ~[?:?]
        at com.mchange.v2.c3p0.stmt.GooGooStatementCache.checkoutStatement(GooGooStatementCache.java:204) ~[?:?]
        at com.mchange.v2.c3p0.impl.NewPooledConnection.checkoutStatement(NewPooledConnection.java:321) ~[?:?]
        at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:455) ~[?:?]
        at org.mule.module.db.internal.domain.connection.DefaultDbConnection.prepareStatement(DefaultDbConnection.java:52) ~[?:?]
        at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.prepareStatement(NoAutoGeneratedKeyStrategy.java:34) ~[?:?]
        at org.mule.module.db.internal.domain.statement.QueryStatementFactory.create(QueryStatementFactory.java:59) ~[?:?]
        at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:44) ~[?:?]
        at org.mule.module.db.internal.processor.UpdateMessageProcessor.doExecuteQuery(UpdateMessageProcessor.java:59) ~[?:?]
        at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42) ~[?:?]
        at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:80) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:80) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:98) ~[?:?]
        at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:55) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:80) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:98) ~[?:?]
        at org.mule.interceptor.AbstractEnvelopeInterceptor.processBlocking(AbstractEnvelopeInterceptor.java:58) ~[?:?]
        at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:98) ~[?:?]
        at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:41) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:98) ~[?:?]
        at org.mule.processor.AbstractRequestResponseMessageProcessor.processBlocking(AbstractRequestResponseMessageProcessor.java:56) ~[?:?]
        at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) ~[?:?]
        at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) ~[?:?]
        at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:80) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61) ~[?:?]
        at org.mule.construct.AbstractPipeline$3.process(AbstractPipeline.java:231) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.chain.SimpleMessageProcessorChain.doProcess(SimpleMessageProcessorChain.java:43) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50) ~[?:?]
        at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:76) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66) ~[?:?]
        at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) ~[?:?]
        at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) ~[?:?]
        at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) ~[?:?]
        at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61) ~[?:?]
        at org.mule.transport.AbstractMessageReceiver.routeEvent(AbstractMessageReceiver.java:511) ~[?:?]
        at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:226) ~[?:?]
        at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:208) ~[?:?]
        at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:145) ~[?:?]
        at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:113) ~[?:?]
        at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16) ~[?:?]
        at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35) ~[?:?]
        at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22) ~[?:?]
        at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30) ~[?:?]
        at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14) ~[?:?]
        at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67) ~[?:?]
        at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44) ~[?:?]
        at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50) ~[?:?]
        at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40) ~[?:?]
        at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41) ~[?:?]
        at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48) ~[?:?]
        at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28) ~[?:?]
        at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13) ~[?:?]
        at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:110) ~[?:?]
        at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30) ~[?:?]
        at org.mule.transport.AbstractReceiverWorker$1.process(AbstractReceiverWorker.java:112) ~[?:?]
        at org.mule.transport.AbstractReceiverWorker$1.process(AbstractReceiverWorker.java:96) ~[?:?]
        at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16) ~[?:?]
        at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67) ~[?:?]
        at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44) ~[?:?]
        at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50) ~[?:?]
        at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40) ~[?:?]
        at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41) ~[?:?]
        at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48) ~[?:?]
        at org.mule.execution.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:65) ~[?:?]
        at org.mule.transport.AbstractReceiverWorker.processMessages(AbstractReceiverWorker.java:179) ~[?:?]
        at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$SubReceiver.onMessage(MultiConsumerJmsMessageReceiver.java:439) ~[?:?]
        at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1394) ~[?:?]
        at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131) ~[?:?]
        at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202) ~[?:?]
        at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) ~[?:?]
        at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_73]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_73]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_73]
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) ~[?:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:304) ~[?:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.prepareStatement(SQLServerConnection.java:1863) ~[?:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.prepareStatement(SQLServerConnection.java:1566) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]
        at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask.run(GooGooStatementCache.java:546) ~[?:?]
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) ~[?:?]
4

3 回答 3

2

好的。

如果您正在使用语句缓存,如果没有适当的缓存语句可用于连接,c3p0 会异步获取缓存的语句。在负载较重且没有仔细配置的情况下,由于服务器拥塞或 c3p0 线程池的拥塞,此异步获取可能需要很长时间。尝试获取 Statement 的客户端无限期地等待,直到成功获取 Statement 或发生异常。

从根本原因异常(向下到堆栈跟踪的底部),很明显,虽然发生了可能很长的 Statement 获取,但要从中获取 Statement 的 Connection 已关闭()或死亡。这就是您需要调试才能真正理解这一点。可能的原因包括:

  1. 在这些情况下,负载/网络问题/神秘的小精灵偶尔会破坏连接,使它们无效并关闭()
  2. DBMS 或某些管理观察者关闭()这些(可能是长时间挂起的)连接,因为打开的连接太多或打开时间过长。(也许这是死锁检测器的工作。)
  3. 您的应用程序(不明智地)在多个线程中使用连接,其中一个调用 close() 而另一个仍在等待()语句。然后池(出于多种原因)尝试关闭()导致此错误的签入连接。

如果(3)是这种情况,您应该停止这样做,但我认为这是最不可能的情况。如果是 (1) 或 (2),您可以缓解问题的主要方法是确保快速获取语句,以便在我们等待语句时不太可能发生坏事。

我要看的第一件事是 c3p0 的线程池在您的应用程序所承受的负载条件下。跟得上吗?(您可以通过 JMX 或通过调用诸如getThreadPoolNumTasksPending()之类的 PooledDataSource 方法来检查这一点,或者,最简单的做法是简单地扩大 c3p0 配置参数numHelperThreads,因此不太可能像 Statement 获取这样的任务被积压。

另一个真正有帮助的配置更改是确保您允许足够数量的缓存语句以防止搅动(不断关闭()并重新获取语句缓存中的连接)。一个非常常见的配置错误是将全局maxStatements配置参数设置为过低的值。获得此权利的简单方法是使用maxStatementsPerConnection而不是全局限制,并将其设置为大约您的应用程序经常使用的 PreparedStatements 数量。

要真正了解正在发生的事情,您需要查看哪些类型的任务正在积压。再次直接在代码中或通过 JMX使用PooledDataSource.sampleThreadPoolStatus() 。

更新:在原始帖子中,您声明“准备好的语句缓存大小将其保持为默认值”。这可能是 mule 的默认设置,但 c3p0 的默认设置是根本不使用语句缓存,maxStatements=0并且maxStatementsPerConnection=0. 您的配置可能不是您认为的那样。禁用语句缓存可能是解决此问题的一种非常简单的方法。

于 2016-10-27T00:03:16.417 回答
1

问题 :

如果您在Oracle 12c 12.2.0.0.0 及更高版本上使用ojdbc8和 NLS_CHARACTERSET WE8ISO8859P15以及返回自动生成的密钥的准备好的语句,它将产生以下错误:

Caused by: java.sql.SQLException: A problem occurred while trying to acquire a cached PreparedStatement in a background thread.
   at com.mchange.v2.c3p0.stmt.GooGooStatementCache.acquireStatement(GooGooStatementCache.java:571)
   at com.mchange.v2.c3p0.stmt.GooGooStatementCache.checkoutStatement(GooGooStatementCache.java:204)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.checkoutStatement(NewPooledConnection.java:321)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:431)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$3.doPrepare(StatementPreparerImpl.java:117)
   at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
   ... 29 more
Caused by: java.sql.SQLException: Invalid argument(s) in call
   at oracle.jdbc.driver.AutoKeyInfo.getNewSql(AutoKeyInfo.java:187)
   at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:4342)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask.run(GooGooStatementCache.java:547)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

解决方案 :

  • 可以使用数据库补丁来解决此问题。
  • 否则您可以将字符集更改为 WE8ISO8859P1

参考

https://support.oracle.com/knowledge/Middleware/2278611_1.html

于 2019-06-13T19:29:31.057 回答
0

我在保存(插入)第一个对象时 hsqldb (2.4.1)遇到了这个问题。hibernate (5.3.1)

创建表 (DDL) 有效,但保存(SQL 准备语句)失败。

hsqldb我没有应用命名策略,hibernate 显然创建了 SQL,其中表名的大小写与预期 的不匹配。

Hsqldb是区分大小写的,虽然人们会期待一个明确的错误消息,但上面的错误被报告了。

该问题已通过添加JPA注释得到解决@Table(name="your_table")

于 2018-07-31T12:55:59.580 回答