没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
java查询一次性查询几十万,几百万数据解决办法
很早的时候写工具用的一个办法。
当时是用来把百万数据打包 成rar文件。
所以用了个笨办法。 希望高手指导一下,有什么好方法没有啊
1、先批量查出所有数据,例子中是一万条一批。
2、在查出数据之后把每次的数据按一定规则存入本地文件。
3、获取数据时,通过批次读取,获得大批量数据。此方法参见:http://yijianfengvip.blog.163.com/blog/static/175273432201191354043148/
以下是查询数据库。按批次查询
public static void getMonthDataList() {
ResultSet rs = null;
Statement stat = null;
Connection conn = null;
List<DataBean> list = new ArrayList<DataBean>();
try {
conn = createConnection();
if(conn!=null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat timesdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowDate = sdf.format(new Date());
Config.lasttimetext = timesdf.format(new Date());
String lastDate = sdf.format(CreateData.addDaysForDate(new Date(), 30));
stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int lastrow = 0;
int datanum = 0;
String countsql = "SELECT count(a.id) FROM trip_special_flight a" +
很早的时候写工具用的一个办法。
当时是用来把百万数据打包 成rar文件。
所以用了个笨办法。 希望高手指导一下,有什么好方法没有啊
1、先批量查出所有数据,例子中是一万条一批。
2、在查出数据之后把每次的数据按一定规则存入本地文件。
3、获取数据时,通过批次读取,获得大批量数据。此方法参见:http://yijianfengvip.blog.163.com/blog/static/175273432201191354043148/
以下是查询数据库。按批次查询
public static void getMonthDataList() {
ResultSet rs = null;
Statement stat = null;
Connection conn = null;
List<DataBean> list = new ArrayList<DataBean>();
try {
conn = createConnection();
if(conn!=null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat timesdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowDate = sdf.format(new Date());
Config.lasttimetext = timesdf.format(new Date());
String lastDate = sdf.format(CreateData.addDaysForDate(new Date(), 30));
stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int lastrow = 0;
int datanum = 0;
String countsql = "SELECT count(a.id) FROM trip_special_flight a" +
yjflinchong
- 粉丝: 671
- 资源: 210
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页