Batch updates using CallableStatement interface.

Explain how to do batch updates using CallableStatement interface.

Batch update is the ability to add more than one statement at once.

CallableStatement.executeBatch() method is used to execute the batch of statements. This will return integer number of records updated, if it returns other than that BatchUpdateException will occur.

For Example:
try

{

   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

   Connection con = DriverManager.getConnection("jdbc:odbc:students");

   Callable Statement c= con.prepareCall(“{Call insert_data(?,?)});

   //set input parameters

   c.setInt(1,10);

   c.setString(2,”ABC”);

   c.addBatch();

   c.setInt(1,11);

   c.setString(2,”DEF”);

   c.addBatch();

   int [] updateCounts = c.executeBatch();

}

catch(BatchUpdateException bu)

{

   System.out.println(bu);

}

catch(SQLException e)

{

   System.out.println(e);

}

catch(ClassNotFoundException e1)

{

   System.out.println(e1);

}
Architecture of a Servet package
Architecture of a Servet package - The javax.servlet package provides interface and classes for writing servlets....
Different Authentication Options available in Servets
Different Authentication Options available in Servets - There are four different options for authentication in servlets...
JDBCRealm
A realm is a collection of pages, images and applications (collectively known as....
Post your comment