java - h2数据库java堆问题
问题描述
我们的应用程序使用 java spring boot 将数据从 avro 文件加载到内存 h2 数据库中。我有 145000000 行要插入,我收到 java 堆错误。它适用于 200 万行。我该如何解决这个问题?
错误粘贴在下面引起:org.h2.jdbc.JdbcSQLNonTransientConnectionException:内存不足。;SQL 语句:在 org.h2.message.DbException.getJdbcSQLException(DbException.java:617) ~[h2-1.4.199.jar:1.4.199] 在 org.h2.message.DbException.getJdbcSQLException(DbException.java:427) ) ~[h2-1.4.199.jar:1.4.199] at org.h2.message.DbException.get(DbException.java:194) ~[h2-1.4.199.jar:1.4.199] at org.h2 .message.DbException.convert(DbException.java:341) ~[h2-1.4.199.jar:1.4.199] at org.h2.command.Command.executeUpdate(Command.java:278) ~[h2-1.4. 199.jar:1.4.199] 在 org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) ~[h2-1.4.199.jar:1.4.199] 在 org.h2.jdbc.JdbcStatement.execute( JdbcStatement.java:205) ~[h2-1.4.199.jar:1.4.199] 在 com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:
解决方案
您正在尝试将 145M 行加载到内存中。所以你显然需要给 JVM 更多的内存来处理这么多的存储量。
查看添加/更改您的-Xmx
JVM 参数以分配更多内存。请参阅此处了解更多信息:
推荐阅读
- ios - Xcode 错误:0x0 的内存读取失败,没有堆栈
- python - boto3 ec2中的分页描述实例
- python - 如何创建循环的东西?
- javascript - 脚本在 Wordpress 中的某些页面上不起作用
- c# - OmniSharp 扩展无法在 Arch VScode 上加载
- ios - 在后台运行应用程序的最佳方式是什么
- javascript - 我怎样才能让我的所有值都显示在我的桌子上?
- android - 二进制 XML 文件第 24 行:在 Vivo 设备中膨胀类 ImageView 时出错
- amazon-web-services - 在最新的 AWS 实例创建中指定的 PEM 文件/密钥在哪里/何时?
- php - 致命错误:无法在 php wordpress 的写入上下文中使用函数返回值