Advertisement

Udemy WW Udemy WW

Thursday 1 December 2011

How can I make batch updates using JDBC?

//Batch Update
import java.sql.*;
class BatchUpdate
{
public static void main(String arg[])
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","student","student");
Statement s=c.createStatement();
String s1="update Emp set name='Mukta' where salary>2300";
String s2="insert into Emp values(124 ,'Mayank',50000) ";
s.addBatch(s1);
s.addBatch(s2);
s.executeBatch();

}
catch(Exception e)
{
System.out.print(e);

}
}
}

No comments:

Post a Comment

Advertisement

Udemy WW