|
How to use batch update in java and jsp
|
|
12-12-2011, 11:38 PM
Post: #1
|
|||
|
|||
|
import java.io.*; import java.sql.*; public class Batch { public static void main(String sam[]) { Connection con; Statement st; ResultSet rs; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:s2sgateway","sa",""); st=con.createStatement(); con.setAutoCommit(false); st.addBatch("insert into emp10 values('jani',201,'indore')"); st.addBatch("insert into emp10 values('safiq',202,'indore')"); st.addBatch("insert into emp10 values('mohamed',203,'indore')"); st.addBatch("insert into emp10 values('kumar',204,'jabalpur')"); st.addBatch("insert into emp10 values('karthik',201,'indore')"); st.addBatch("insert into emp10 values('rita',201,'indore')"); st.executeBatch(); System.out.println("one record inserted"); con.commit(); con.setAutoCommit(true); st.close(); con.close(); } catch(Exception e){} } } Try it and ask questions if any doubt and do comment us. Happy coding
|
|||
Advertise here or at any positions around our site send a mail to info@walkinsforum.com
|
« Next Oldest | Next Newest »
|
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
User(s) browsing this thread: 1 Guest(s)






![[-]](images/royal_red/collapse.gif)






