数据库连接问题

Caused by: com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: Out of memory (Needed 8385840 bytes)

at com.jfinal.plugin.activerecord.DbPro.doPaginate(DbPro.java:509)

at com.jfinal.plugin.activerecord.DbPro.paginate(DbPro.java:1253)

at com.jfinal.plugin.activerecord.Db.paginate(Db.java:656)

at com.ofsoft.cms.front.template.directive.HouseDirective.onRender(HouseDirective.java:76)

at com.ofsoft.cms.front.template.freemarker.TagBase.execute(TagBase.java:36)

at freemarker.core.Environment.visit(Environment.java:333)

at freemarker.core.UnifiedCall.accept(UnifiedCall.java:100)

at freemarker.core.Environment.visit(Environment.java:257)

at freemarker.core.MixedContent.accept(MixedContent.java:57)

at freemarker.core.Environment.visit(Environment.java:257)

at freemarker.core.Environment.process(Environment.java:235)

at freemarker.template.Template.process(Template.java:262)

at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:158)

... 30 more

Caused by: java.sql.SQLException: Out of memory (Needed 8385840 bytes)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)

at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2118)

at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1992)

at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3403)

at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:471)

at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3115)

at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2344)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2739)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2495)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1903)

at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2011)

at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)

at com.jfinal.plugin.activerecord.DbPro.query(DbPro.java:80)

at com.jfinal.plugin.activerecord.DbPro.doPaginateByFullSql(DbPro.java:523)

at com.jfinal.plugin.activerecord.DbPro.doPaginate(DbPro.java:507)

... 42 more


评论区

JFinal

2020-01-13 13:02

一次性查出来的数据太多,撑破了你的 JVM 内存,注意这个异常:
Out of memory

注意在 sql 语句中用好 where 子句,限定数据量的大小,还要注意 select 中一般不要用 "select *" , 而是用到多少字段就 select 什么字段

chcode

2020-01-13 20:18

https://jfinal.com/share/1865 大数据量处理

yq95279527

2020-01-14 16:30

@JFinal 目前jvm虚拟机配置的内存为8G,应该不止是一次查询的问题,但是又不知道该怎么排查@chcode

yq95279527

2020-01-14 16:31

@chcode 好的,试试这个方式,主要是字段中包含文本比较多,数据量不大

JFinal

2020-01-14 17:22

@yq95279527 用 JDK 自带的 VisualVM 来分析,一般是两种情况:
1: 内存泄漏
2: 内存分配太快,以至于内存回收来不及

JFinal

2020-01-14 17:22

强调一下,这两个问题与 jfinal 都是无关的,取决于你自己的代码

yq95279527

2020-01-14 17:24

@JFinal 好的,目前使用的jfinal3.2版本,性能上区别应该不会太大是吧

JFinal

2020-01-14 17:27

@yq95279527 性能上无差别, 用法是一样的,建议升级,这里有极其简单的升级文档:
https://jfinal.com/doc/14-1

热门反馈

扫码入社