java.lang.OutOfMemoryError: Java heap space error when performing millions of queries

In my application, I need to perform millions of queries to MySQL database. The codes look as follows: for (int i=0; i< num_rows ; i++) { String query2="select id from mytable where x='"+ y.get(i) "'"; Statement stmt2 = Con0.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet rs2 = stmt2.executeQuery(query2); ... // process result in rs2 rs2.close(); } where num_rows is around 2 million. After 600k loops, java report an error and exit: > java.lang.OutOfMemoryError: Java heap space error. What's wrong in my codes? How should I avoid such an error? Thanks in advance!
what exactly are you doing here with the data?

以上就是java.lang.OutOfMemoryError: Java heap space error when performing millions of queries的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准