一、PreparedStatement.addbatch() 方法使于批量执行SQL语句。使用方法如下:
1.预编译SQL语句:
PreparedStatement statement = connection.prepareStatement("INSERT INTO TABLEX VALUES(?, ?)");
2.为SQL插入值:
statement.setInt(1, 1);
statement.setString(2, "Cujo");
statement.addBatch();
statement.setInt(1, 2);
statement.setString(2, "Fred");
statement.addBatch();
statement.setInt(1, 3);
statement.setString(2, "Mark");
statement.addBatch();
3.批量执行上面3条语句.
1.预编译SQL语句:
PreparedStatement statement = connection.prepareStatement("INSERT INTO TABLEX VALUES(?, ?)");
2.为SQL插入值:
statement.setInt(1, 1);
statement.setString(2, "Cujo");
statement.addBatch();
statement.setInt(1, 2);
statement.setString(2, "Fred");
statement.addBatch();
statement.setInt(1, 3);
statement.setString(2, "Mark");
statement.addBatch();
3.批量执行上面3条语句.
int [] counts = statement.executeBatch();
Servlet中的八大Listener
Hibernate.cfg.xml配置的用户名和密码加密
关于抽象类和接口
求助:java编程中如何获取当前日期
求教:如何用类反射机制调用get方法?
北京招聘Java开发程序员
轩辕互动(Exoweb)招聘软件开发工程师
spring的注入机制(转载)
帮帮我
★互助式IT培训.【大侠老师广发英雄贴】组织一次全国性的IT技术免费学习机会★