六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 82|回复: 0

批量添加数据库

[复制链接]

升级  9.67%

67

主题

67

主题

67

主题

举人

Rank: 3Rank: 3

积分
229
 楼主| 发表于 2013-2-7 18:54:15 | 显示全部楼层 |阅读模式
http://www.51.la/report/1_main.asp?id=1  统计流量的网页
http://blog.sina.com.cn/s/blog_59befbb60100ab01.html   spring定时网页

select count(*) from APPLY_OPEN a where to_char(a.add_date,'yyyy-MM-dd') = (select to_char
(sysdate,'yyyy-MM-dd') from dual)

select count(*) from APPLY_OPEN a where to_char(a.add_date,'yyyy-MM') = (select to_char
(sysdate,'yyyy-MM') from dual)

select count(*) from APPLY_OPEN a where to_char(a.add_date,'yyyy') = (select to_char
(sysdate,'yyyy') from dual)



Session session = sessionFactory.openSession();
   Transaction tx = session.beginTransaction();   
   for ( int i=0; i<100000; i++ ) {
    Customer customer = new Customer(.....);
    session.save(customer);
    if ( i % 20 == 0 ) {
      //20,与JDBC批量设置相同
       //将本批插入的对象立即写入数据库并释放内存
        session.flush();
       session.clear();
    }
  }
   
  tx.commit();
  session.close();
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表