java读取mysql由于数据过大出现这个异常怎么解决
来源:百度知道 编辑:UC知道 时间:2024/06/27 07:09:51
用如下代码读取数据:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/atse?useUnicode=true&characterEncoding=utf-8","xxxx","xxxx");
Statement stmt = conn.createStatement();
ResultSet rst=stmt.executeQuery("select * from atse_flight limit 100001,200001");
while(rst.next){
//对数据处理
}
出现的异常是Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
请问怎么解决啊。
由于以前不怎么上百度知道 所以没有分 给了。。以后我会多多帮助比我还新的人的。
有高手闲来无事就帮帮忙吧 我这不胜感激。
首先非常感谢两位帮忙
使用 select top 1000 * from atse_flight limit 100001,200001
会出现下面的异常
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1000 * from atse_flight limit 100001,200001' at line 1
如果把java虚拟机改了的话,感觉是治标不治本,因为我们公司还
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/atse?useUnicode=true&characterEncoding=utf-8","xxxx","xxxx");
Statement stmt = conn.createStatement();
ResultSet rst=stmt.executeQuery("select * from atse_flight limit 100001,200001");
while(rst.next){
//对数据处理
}
出现的异常是Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
请问怎么解决啊。
由于以前不怎么上百度知道 所以没有分 给了。。以后我会多多帮助比我还新的人的。
有高手闲来无事就帮帮忙吧 我这不胜感激。
首先非常感谢两位帮忙
使用 select top 1000 * from atse_flight limit 100001,200001
会出现下面的异常
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1000 * from atse_flight limit 100001,200001' at line 1
如果把java虚拟机改了的话,感觉是治标不治本,因为我们公司还
设置java虚拟机运行参数:
如:
-Xms64m
-Xmx256m
如果你用的是Eclipse的话,
可以在菜单中选
run -> run configurations
打开Run configurations的对话框,
在(x)Arguments选项卡中,VMarguments的那个textbox中,
写上
-Xms64m
-Xmx256m
就可以了,
-Xms是java虚拟机初始化时分配的内存,
-Xmx是java虚拟机运行是可以使用的最大内存。
select top 1000 * from atse_flight limit 100001,200001
mysql可以维护的单表数据最大就是4G。你可以做多个Rs来分别处理就好