关于Mysql结果集过大的问题?
表里的记录有几百万条,直接取出
如下:
public ResultSet getRS() throws Exception {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = getConnection();
String query = "select * from user_month";
stmt = con.createStatement();
rs = stmt.executeQuery(query);
}
catch(Exception e){
e.printStackTrace();
}
return rs;
}
那么程序运行时会出现Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
那么应该怎么取才不会出现这类异常,谢谢?