hibernate 使用jdbc批量插入数据
来源:互联网 发布:淘宝客服晚上几点下班 编辑:程序博客网 时间:2024/05/22 03:33
@Autowired @Qualifier("sessionFactory") protected SessionFactory sessionFactor Session session = sessionFactory.openSession();Transaction tx = session.beginTransaction();session.doWork(new Work() {int count = 0;@Overridepublic void execute(Connection conn) throws SQLException {String sql = "INSERT INTO terminalxmltemp (tsn, orgId, typeId, flag, isEnable, errorMsg) VALUES (?, ?, ?, ?, ?, ?)";PreparedStatement ps = conn.prepareStatement(sql);for (TerminalXmlForm terminalXmlForm : terminals) {ps.setString(1, terminalXmlForm.getTsn());ps.setLong(2, terminalXmlForm.getGroupId());ps.setLong(3, terminalXmlForm.getTypeId());ps.setString(4, terminalXmlForm.getFlag());ps.setString(5, terminalXmlForm.getIsEnable());ps.setString(6, terminalXmlForm.getErrorMsg());ps.addBatch();if (++count % 1000 == 0) {ps.executeBatch();}}ps.executeBatch();}});tx.commit();session.close();
sessionFactory 在spring配置文件中配置
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
0 0
- hibernate 使用jdbc批量插入数据
- hibernate使用jdbc批量插入
- Hibernate使用jdbc批量插入
- hibernate使用jdbc批量插入
- java中批量插入数据jdbc hibernate Mybatis使用方式
- 使用JDBC批量插入数据
- jdbc批量插入数据
- JDBC批量插入数据
- Hibernate、JDBC之批量插入
- 利用hibernate jdbc 批量插入
- hibernate批量插入数据
- Hibernate批量插入数据
- hibernate批量插入数据
- 使用JDBC在MySQL数据库中快速批量插入数据
- 使用JDBC在MySQL数据库中快速批量插入数据
- 使用JDBC在MySQL数据库中快速批量插入数据
- 使用JDBC在MySQL数据库中快速批量插入数据
- 使用JDBC在MySQL数据库中快速批量插入数据
- TFS 2010:服务器不提供Team Foundation服务,HTTP代码503,Service Unavailable
- SQL一些最基础的知识
- 欢迎使用CSDN-markdown编辑器
- Bundle类 android基础一
- swift开发中No such module 'Cocoa' 错误
- hibernate 使用jdbc批量插入数据
- 1877: [SDOI2009]晨跑
- input_open_file()浅析
- Virtualbox正在运行虚拟机,被强制中断导致虚拟机无法启动(start按钮为灰色)解决方案
- Struts2 Convention Plugin ( struts2 零配置 )
- 向上转型的理解
- Android之如何解决popupWindow(pw.setFocusable(true))按返回键和menu键退出
- List,set,Map 的用法和区别
- iOS自定义TabBar