掲示板

Custom Query: You can't operate on a closed Connection

7年前 に Waqas Rehman によって更新されました。

Custom Query: You can't operate on a closed Connection

New Member 投稿: 24 参加年月日: 13/01/17 最新の投稿
Hi,

I have developed a custom Portlet using Liferay 6.2 SDK which retrieves data using custom sql query in Finder method. When ever I deploy the Portlet and try it access it for the very first time I get the following error. This error disappears on any subsequent accesses and portlet works perfectly fine.


Caused by: java.sql.SQLException: You can't operate on a closed Connection!!!
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:77)
	at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:171)
	at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
	at com.sun.proxy.$Proxy2.prepareStatement(Unknown Source)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
	at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
	at org.hibernate.loader.Loader.doQuery(Loader.java:801)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
	at org.hibernate.loader.Loader.doList(Loader.java:2542)
	... 249 more
Caused by: java.lang.NullPointerException
	at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:135)

thumbnail
7年前 に Olaf Kock によって更新されました。

RE: Custom Query: You can't operate on a closed Connection

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Waqas Rehman:
I have developed a custom Portlet using Liferay 6.2 SDK which retrieves data using custom sql query in Finder method.


Is that in ServiceBuilder or in custom hibernate code? If it's custom code and only happens on the very first clal, you might connect to the database too late. If it's ServiceBuilder: Which version? (Liferay as well as your SDK)