这篇文章来自http://asialee.iteye.com/blog/949250,感谢知识共享的人
检测数据库是否支持batch
DatabaseMetaData.supportsBatchUpdates()
然后就是三个比较有用的方法:
addBatch: 将Statement, PreparedStatement, and CallableStatement添加进batch里面
executeBatch: 返回各个语句的执行结果
clearBatch: 将batch里面的sql语句清除掉
在这个里面有一个值得注意的是要设置connection的事务提交类型
setAutoCommit(false)为手动提交
// Create statement object Statement stmt = conn.createStatement(); // Set auto-commit to false conn.setAutoCommit(false); // Create SQL statement String SQL = "INSERT INTO Employees (id, first, last, age) " + "VALUES(200,'Zia', 'Ali', 30)"; // Add above SQL statement in the batch. stmt.addBatch(SQL); // Create one more SQL statement String SQL = "INSERT INTO Employees (id, first, last, age) " + "VALUES(201,'Raj', 'Kumar', 35)"; // Add above SQL statement in the batch. stmt.addBatch(SQL); // Create one more SQL statement String SQL = "UPDATE Employees SET age = 35 " + "WHERE id = 100"; // Add above SQL statement in the batch. stmt.addBatch(SQL); // Create an int[] to hold returned values int[] count = stmt.executeBatch(); //Explicitly commit statements to apply changes conn.commit();
相关推荐
主要介绍了使用批处理脚本在特定目录中启动Git-Bash窗口,需要的朋友可以参考下
简单的Bash脚本到Windows批处理文件转换器将bash脚本( *.sh )转换为Windows批处理文件( *.bat )。 这不应该是一个完全完整/正确的工具,而是转换脚本时的起点。 对于简单的脚本,这可能会创建正确的结果。 在线...
macos系统tar命令加密压缩文件 解密压缩文件 批处理shell bash 脚本
macos系统tar命令加密压缩文件 解密压缩文件 批处理shell bash 脚本
linux 服务器GNU Bash小于版本4.3有操作系统命令注入漏洞,需要对bash升级,下载解压 #tar zxvf bash-4.4.tar.gz #cd bash-4.4 #./configure (如果centos7编译失败,请先安装#yum install gcc) #make #make ...
bash官方手册/Bash Reference Manual
BASH官方文档,BASH官方文档,BASH官方文档
bash 入门经典 不可不看哦 bash 入门经典 不可不看哦 bash 入门经典 不可不看哦
RHCERHCE bash RHCE bash RHCE bash RHCE bash RHCE bash RHCE bash RHCE bash bash
官方的bash手册 讲述bash脚本语法规范 和linux相关配置 很好的资料
redhat bash漏洞补丁包含文件:bash-4.1.2-15.el6_5.2.i686.rpmbash-4.1.2-15.el6_5.2.x86_64.rpmbash-3.0-27.el4.i386.rpmbash-3.0-27.el4.x86_64.rpmbash-3.2-33.el5_11.4.i386.r... redhat bash漏洞补丁 包含文件...
bash-3.0-27.0.3.el4.i386.rpm bash-debuginfo-3.0-27.el4.4.i386.rpm 2、rhel 4.x 64位 bash-3.0-27.el4.x86_64.rpm bash-debuginfo-3.0-27.el4.4.x86_64.rpm 3、centos5.x_32 bash-3.2-33.el5.1.i386.rpm bash-3.2...
鉴于目前绝大部分服务器因为没有注册的yum或者因不通外网等问题导致无法使用yum update -y bash 命令进行漏洞修复,如采用RPM包升级修复漏洞又存在各服务器系统有的是32位有的是64位或者bash的版本不一样导致需要...
git-bash.exe
bbips-Bash批处理图像处理脚本。 使用Imagemagick来“批处理” bash脚本的集合一次处理了整个图像目录。 与Linux和Unix系统一起使用,以从bash shell批处理* .jpg图像文件。
bash.bash_logout888
linux平台的bash shell开发帮助文档(手册),英文版,版本4.2。日常开发shell翻阅, 章节如下: Definitions:: Some definitions used i n the rest of this manual. Basic Shell Features:: The shell "building ...
Bash使用
bash shell 连接数据库批量跑数据
This thoroughly revised edition of bash Cookbook teaches shell scripting the way Unix masters practice the craft. Three Unix veterans present a variety of recipes and tricks for all levels of shell ...