在数据库中执行一个批处理SQL语句
With batch updating, a set of SQL statements is assembled and then sent altogether to the database for execution. Batch updating can improve performance.
This example creates a batch of insert statements. Auto-commit is disabled so that you have the choice of committing or not in the event of an exception.
java 代码
- try {
-
- connection.setAutoCommit(false);
-
-
- String sql = "INSERT INTO my_table VALUES(?)";
- PreparedStatement pstmt = connection.prepareStatement(sql);
-
-
- for (int i=0; i<10; i++) {
- pstmt.setString(1, ""+i);
- pstmt.addBatch();
- }
-
-
- int [] updateCounts = pstmt.executeBatch();
-
-
-
-
- processUpdateCounts(updateCounts);
-
-
- connection.commit();
- } catch (BatchUpdateException e) {
-
- int[] updateCounts = e.getUpdateCounts();
-
-
-
-
- processUpdateCounts(updateCounts);
-
-
- connection.rollback();
- } catch (SQLException e) {
- }
-
- public static void processUpdateCounts(int[] updateCounts) {
- for (int i=0; i<updateCounts.length; i++) {
- if (updateCounts[i] >= 0) {
-
- } else if (updateCounts[i] == Statement.SUCCESS_NO_INFO) {
-
- } else if (updateCounts[i] == Statement.EXECUTE_FAILED) {
-
- }
- }
- }
分享到:
相关推荐
将powerDesigner的概念模型转换成物理模型,生成sql文件导入数据库.
终于找到一个好用的东西。ruby-pinyin。现在介绍给大家。 里面自带api。用法也很简单。 在rails 中 把 pinyin.rb 及 dict 放到lib目录中。 在模型中引入文件。 require "pinyin" 按后实例化一个pinyin py = ...
soho网络zhuan钱的体会.doc
支持移动端的转盘抽奖,点击抽奖实现转盘抽奖,奖励在json文件中定义,也可以改成接口从后台获取,也可指定抽到的奖。
可以方便的将csv文件导入到sqlite数据库中,注意csv一定要utf-8格式,否则导入时会出乱码。
Delphi 将Foxpro表转换为Paradox表,可能不太常用,不过也算是一个简单的数据库格式转换程序吧,或许对编写数据库开发程序有些许帮助。注:本程序运行后会直接读取DBF文件,若DBF报表文件不存在,程序会弹出错误信息...
按后实例化一个pinyin py = PinYin.instance py.to_pinyin_abbr("刘德华") #=> ldh py.to_permlink('中文轉漢語拼音') #=> "zhong-wen-zhuan-han-yu-pin-yin" py.to_pinyin('中文轉漢語拼音',separator = '-', ...
map、 key' 和 value 的 取值 and so on
本人转的别人写的人工神经网络的学习体会与感受,真是受益匪浅啊!
2.6.14 内核移植说明文档 如果你是新下载的内核,那这一步就不用了。但如果你用的是别人移植好的内核,那最好在编译内核之前先清除一下中间文件,因为你们用来编译内核的交叉编译工具可能不同。
zhuan-kai-fa
重构是迅速发现并修复有问题的代码的一种高效的方式。在《代码重构(c # & asp.net版)》中首次提供了在c#和asp.net中进行重构的专业方法,您将学习如何运用重构技术管理和修改代码
Android游戏源码最简单的打砖块游戏
是蚂蚁集团开源的基于 Spring Boot 的研发框架,它在 Spring Boot 的基础上,提供了诸如 Readiness Check,类隔离,日志空间隔离等等能力。
主要用于路径规划,程序读入之初,需要先读入Kinect相机拍摄的深度图像。
bai_zhuan=(int)zhuan/100; shi_zhuan=(int)zhuan0/10; ge_zhuan=(int)zhuan; write_data(table[bai_fen]); write_data(table[shi_fen]); write_data(table[ge_fen]); write_data(table[12]); write...
Deep Snake for Real-Time Instance Segmentation pytorch1.0 cuda8转6个pt
mapgis二次开发转为jpg的功能,可以完美转换mapgis图形为jpg光栅图。
pdf转txt格式,可以将pdf转换成txt格式的小程序,
短浮点数与十六进制互相转换程序,这是我写一个通信程序时写的,各位同学写这个时,可以拿去做验证。