欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

内存溢出 Caused by: java.sql.SQLException: Error Caused by: java.lang.OutOfMemoryError: Java heap space

程序员文章站 2022-06-13 21:30:05
...

服务器运行的定时任务,五分钟查询一次数据库,发现运行一段时间后会导致内存溢出,记录下解决过程。

org.springframework.jdbc.UncategorizedSQLException: 
### Error querying database.  Cause: java.sql.SQLException: Error
### The error may exist in file [E:\auitvideo3.1_tomcat\webapps\auitvideo3.1\WEB-INF\classes\mybatis\front\DrugMapper.xml]
### The error may involve DrugMapper.getAllNoXiaoShou-Inline
### The error occurred while setting parameters
### SQL: SELECT     tpr_seq_id,     cons_seq_id,     tpr_creat_time,     tpr_soruce,     tpr_name,     tpr_age,     tpr_sex,     tpr_address,     tpr_phone,     tpr_dept,     tpr_diagnostic,     tpr_content,     tpr_img_data,     tpr_doctor,     tpr_deployment,     tpr_lr_rq,     prescribe_type,     auit_memo,     audit_state,     tpr_buy_name,     tpr_buy_no,     pass_id,     erpNo,     tpr_status,     tpr_oper,     tpr_fy,     pass_name,     org_name,     org_area,     tpr_pihao,     pass_user_type,     shenhe_time,     tpr_tpr,     tpr_hfr,     xiaoshou_time,     is_xiaoshou   FROM tbl_prescription_xs where is_xiaoshou='0'
### Cause: java.sql.SQLException: Error
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
	at $Proxy14.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
	at com.fh.dao.DaoSupport.findForList(DaoSupport.java:119)
	at com.fh.service.front.DrugService.getAllNoXiaoShou(DrugService.java:396)
	at com.fh.service.front.DrugService$$FastClassBySpringCGLIB$$deb5feb8.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
	at com.fh.service.front.DrugService$$EnhancerBySpringCGLIB$$7fb65008.getAllNoXiaoShou(<generated>)
	at com.fh.util.GetERPXiaoShou.scheduledScore2(GetERPXiaoShou.java:36)
	at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
	at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Error
Caused by: java.lang.OutOfMemoryError: Java heap space
	at java.nio.HeapCharBuffer.<init>(Unknown Source)
	at java.nio.CharBuffer.allocate(Unknown Source)
	at java.nio.charset.CharsetDecoder.decode(Unknown Source)
	at java.nio.charset.Charset.decode(Unknown Source)
	at com.mysql.jdbc.StringUtils.toString(StringUtils.java:2156)
	at com.mysql.jdbc.ResultSetRow.getString(ResultSetRow.java:689)
	at com.mysql.jdbc.BufferRow.getString(BufferRow.java:523)
	at com.mysql.jdbc.ResultSetImpl.extractStringFromNativeColumn(ResultSetImpl.java:932)
	at com.mysql.jdbc.ResultSetImpl.getNativeConvertToString(ResultSetImpl.java:3416)
	at com.mysql.jdbc.ResultSetImpl.getNativeString(ResultSetImpl.java:4229)
	at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5352)
	at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5162)
	at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5201)
	at com.alibaba.druid.filter.FilterChainImpl.resultSet_getString(FilterChainImpl.java:811)
	at com.alibaba.druid.filter.stat.StatFilter.resultSet_getString(StatFilter.java:930)
	at com.alibaba.druid.filter.FilterChainImpl.resultSet_getString(FilterChainImpl.java:809)
	at com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl.getString(ResultSetProxyImpl.java:693)
	at com.alibaba.druid.pool.DruidPooledResultSet.getString(DruidPooledResultSet.java:257)
	at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:59)
	at $Proxy29.getString(Unknown Source)
	at org.apache.ibatis.type.StringTypeHandler.getNullableResult(StringTypeHandler.java:34)
	at org.apache.ibatis.type.StringTypeHandler.getNullableResult(StringTypeHandler.java:23)
	at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:51)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.applyAutomaticMappings(FastResultSetHandler.java:348)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.getRowValue(FastResultSetHandler.java:272)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:221)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:193)
	at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:159)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57)

DrugMapper.xml 的getAllNoXiaoShou 查询方法报错。

### The error occurred while setting parameters 英文不好,翻译软件说 “设置参数时发生错误” 但是并没有传参。

<select id="getAllNoXiaoShou" parameterType="pd" resultType="pd">

猜测可能是 parameterType="pd" 影响。 删掉这句继续监测看看