title: SQL Error: 0, SQLState: null
body: <p>I am getting the following exception. Can anyone help when this error occurs?
  This error occur randomly. sometime it occurs in one table and sometime in another. I am not able to identify the exact cause. </p>
  
  <pre><code>  11:13:24,223 WARN    localhost-startStop-1 [JDBCExceptionReporter] - SQL Error: 0, SQLState: null
      11:13:24,224 ERROR   localhost-startStop-1 [JDBCExceptionReporter] - Connection has already been closed.
      11:13:24,356 ERROR   localhost-startStop-1 [OMSStartupServiceImpl] - Error occured while initializing state agent ...
      org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [select this_.id as id41_0_, this_.code as code41_0_, this_.description as descript3_41_0_, this_.label as label41_0_, this_.value as value41_0_ from order_status this_]; SQL state [null]; error code [0]; could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query
              at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:651)
              at org.springframework.orm.hibernate3.HibernateExceptionTranslator.convertHibernateAccessException(HibernateExceptionTranslator.java:89)
              at org.springframework.orm.hibernate3.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:68)
              at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
              at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
              at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
              at com.snapdeal.oms.aspect.LogAspectHandler.profile(LogAspectHandler.java:120)
              at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
              at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
              at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
              at com.snapdeal.oms.dao.order.impl.OrderDaoImpl$$EnhancerByCGLIB$$610008c6.getOrderStatus(&lt;generated&gt;)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl.loadStateAgent(OMSStartupServiceImpl.java:1141)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl.loadAll(OMSStartupServiceImpl.java:312)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl.loadCache(OMSStartupServiceImpl.java:831)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl.loadAllAtStartup(OMSStartupServiceImpl.java:729)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl$$FastClassByCGLIB$$e485a1ab.invoke(&lt;generated&gt;)
              at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
              at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
              at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
              at com.snapdeal.oms.aspect.LogAspectHandler.profile(LogAspectHandler.java:120)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
              at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
              at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
              at com.snapdeal.oms.services.order.impl.OMSStartupServiceImpl$$EnhancerByCGLIB$$136301b3.loadAllAtStartup(&lt;generated&gt;)
              at com.snapdeal.web.listener.OMSContextListener.contextInitialized(OMSContextListener.java:34)
              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
              at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
              at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
              at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
              at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
              at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
              at org.hibernate.loader.Loader.doList(Loader.java:2216)
              at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
              at org.hibernate.loader.Loader.list(Loader.java:2099)
              at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
              at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
              at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
              at com.snapdeal.oms.dao.order.impl.OrderDaoImpl.getOrderStatus(OrderDaoImpl.java:1715)
              at com.snapdeal.oms.dao.order.impl.OrderDaoImpl$$FastClassByCGLIB$$368010d2.invoke(&lt;generated&gt;)
              at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
              at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
              at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
              ... 56 more
      Caused by: java.sql.SQLException: Connection has already been closed.
              at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:117)
              at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
              at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
              at com.sun.proxy.$Proxy35.prepareStatement(Unknown Source)
              at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
              at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
              at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
              at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
              at org.hibernate.loader.Loader.doQuery(Loader.java:673)
              at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
              at org.hibernate.loader.Loader.doList(Loader.java:2213)
              ... 67 more
  </code></pre>