Wednesday 4 January 2017

Textual Representation of logo

GC overhead limit exceeded Out Of Memory Error In JDBC

I have encountered this error when i was trying to insert a big list of object in to database , using jdbc . The list size was approximately 100k . One way to resolve this error to increase your memory size . I double checked my code and found that i have not closed the PreparedStatement Object in my DAO class .

java.lang.OutOfMemoryError: GC overhead limit exceeded
 at java.util.Calendar$Builder.build(Calendar.java:1482)
 at sun.util.locale.provider.CalendarProviderImpl.getInstance(CalendarProviderImpl.java:88)
 at java.util.Calendar.createCalendar(Calendar.java:1666)
 at java.util.Calendar.getInstance(Calendar.java:1655)
 at java.text.SimpleDateFormat.initializeCalendar(SimpleDateFormat.java:657)
 at java.text.SimpleDateFormat.(SimpleDateFormat.java:601)
 at com.mysql.jdbc.PreparedStatement.setTimestampInternal(PreparedStatement.java:4321)
 at com.mysql.jdbc.PreparedStatement.setTimestamp(PreparedStatement.java:4274)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
 at ch.koala.dao.ProductDAO.insert(ProductDAO.java:42)
 at ch.koala.services.ProductSyncJob.execute(ProductSyncJob.java:64)
 at ch.koala.services.RestServices.productSyncJobExecute(RestServices.java:4020)
 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:497)
 at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:187)
 at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:71)
 at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:280)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1341)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1273)
 at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1223)
 at org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:159)
 at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
 at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
 at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:238)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)

So to solve this issue , if you encounter while using JDBC , just call close method on your PreparedStatement object , after you finished your work on that , and you might get rid of this error .


Please Post Comments and Suggestions !!!