Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
JDBC batch update is a collectively called when a
group of SQL statements are executed simultaneously to a database
as a single unit.
The batch is sent to the
database in a single request using connection object. The
advantage of batch is to reduce the network calls between
the
front end application and its database
rather than executing single SQL statement.
Please take a look at the example below.
con = DriverManager.getConnection(url + db, user, pass);
con.setAutoCommit(false);// Disables auto-commit.
st = con.createStatement();
st.addBatch("update person set
cname='Smith' where
id='1'");
st.addBatch("update person set
cname='Dave' where
id='2'");
st.addBatch("update person set
cname='Chris' where
id='3'");
st.executeBatch();
String sql =
"select * from person";
rs
= st.executeQuery(sql);
System.out.println("No Name");
while (rs.next()) {
System.out.print(rs.getString(1) + " \t");
System.out.println(rs.getString(2));
}
rs.close();
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.