Recent Posts
- NCC Punjab LDC Results 2013 NCCPunjab.com Interview Selected Candidates List
- RGUHS PGSSET Super Speciality 2013 Exam www.logisys.net.in Online Application
- RKCL RS-CIT Results 2013 rkcl.in RSCIT Final Exam May Result 2013
- TNEB Electricity Bills Online Payment tnebnet.org/awp/login Tamilnadu EB Payment System
- Kerala LET 2013 Fee Structure for 2013-14 Engineering College Admission
Discussion Forum
Batch Update in Java with Example Program
Batch Update in Java with Example Program. This Java Batch Update DB (database) example describes the basic operations performed on the JDBC Batch Update database connectivity code.
Batch Update in Java with Example Program. This Java Batch Update DB (database) example describes the basic operations performed on the JDBC Batch Update database connectivity code.In this example you will learn about how to write java code for Batch Update with oracle database.
Program:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class BatchUpdationDemo {
public static void main(String args[]){
Connection con=null;
Statement st = null;
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:ORCL”,”scott”,”tiger”);
st = con.createStatement();
st.addBatch(“insert into eshusoft values(‘myuser’,'mypwd’)”);
st.addBatch(“update eshusoft set password=’mypwd2′
where username=’myuser’”);
st.addBatch(“delete from eshusoft where username=’myuser’”);
int b[] = st.executeBatch();
System.out.print(“rows updated: “+ b.length);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Result:
rows updated : 3
