import java.sql. * ; public class TestPrepStmt ... { public static void main(String[] args) ...{ PreparedStatement pstmt = null; Connection conn = null; try ...{ Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost/data?user=root&password=123456"; conn = DriverManager.getConnection(url); pstmt = conn.prepareStatement("insert into user values (?, ?, ?)"); pstmt.setInt(1, 11); pstmt.setString(2, "aaaaa"); pstmt.setString(3, "aaaaa"); pstmt.addBatch(); pstmt.setInt(1, 12); pstmt.setString(2, "bbbbb"); pstmt.setString(3, "bbbbb"); pstmt.addBatch(); pstmt.setInt(1, 13); pstmt.setString(2, "ccccc"); pstmt.setString(3, "ccccc"); pstmt.addBatch(); pstmt.setInt(1, 14); pstmt.setString(2, "ddddd"); pstmt.setString(3, "ddddd"); pstmt.addBatch(); pstmt.executeBatch(); } catch (ClassNotFoundException e) ...{ e.printStackTrace(); } catch (SQLException e) ...{ e.printStackTrace(); } finally ...{ try ...{ if(pstmt != null) ...{ pstmt.close(); pstmt = null; } if(conn != null) ...{ conn.close(); conn = null; } } catch (SQLException e) ...{ e.printStackTrace(); } } }}