Essentially, the Addbatch () method using statement and Prestatement
Code
import java.sql.*;p ublic class getconnection{public static void Main (string[] args) { Access2database adb=new access2database (); Connection conn=adb.getconn ();//transaction dealingpreparedstatement Pstam=null;try{conn.setautocommit (false); String sql= "INSERT into student (Name,major,score) values (?
,?,?); "; Pstam=conn.preparestatement (SQL);p stam.setstring (1, "F");p stam.setstring (2, "history");p Stam.setint (3, 67); Pstam.addbatch ();p stam.setstring (1, "H");p stam.setstring (2, "biology");p Stam.setint (3,);p stam.addbatch (); Pstam.executebatch (); Conn.commit ();} catch (SQLException e) {try {conn.rollback ();} catch (SQLException E1) {//TODO auto-generated catch Blocke1.printstacktrace ();} E.printstacktrace ();} Finally{try {Conn.setautocommit (true);} catch (SQLException e) {//TODO auto-generated catch Blocke.printstacktrace ();}} Release the resource of the Programtry{pstam.close (); Conn.close ();} catch (SQLException e) {e.printstacktrace ();}}}
Java language MySQL batch processing