❮ Previous Next ❯

JDBC Batch Processing

In JDBC batch processing we can execute a batch (group) of sql statements, instead of a single sql statement. It makes the faster performance.

The java.sql.Statement and java.sql.PreparedStatement interfaces provide two methods for batch processing, such as addBatch() method and executeBatch() method.

Method                                                                     Description
void addBatch(String query). It adds query into batch.
int[] executeBatch(). It executes the batch of queries.

Let's see a demo program for batch processing in jdbc.

import java.sql.*;
class JdbcDemo5
public static void main(String args[])throws Exception
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
Statement st=con.createStatement();
st.addBatch("insert into student values(1o1,'akshay')");
st.addBatch("insert into user420 values(191,'santosh')");
st.executeBatch(); //executing the batch

If you see the table student, two records has been added.

first we will create a table student as : create table student(regdno varchar2(25), name char(45));

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved