package org.llgc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class SQL2 { public static void main (String[] args) { try { Class.forName ("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace (); return; } String url = "jdbc:mysql://localhost/elearning"; try (Connection cn = DriverManager.getConnection (url, "root", "aui"); PreparedStatement pstmt = cn .prepareStatement ("INSERT INTO civilite (LibelleCourt, LibelleLong) Values (?, ?)");) { pstmt.setString (1, "Pr"); pstmt.setString (2, "Président"); // Compilation au niveau serveur pstmt.executeUpdate (); pstmt.clearParameters (); pstmt.setString (1, "Ch"); pstmt.setString (2, "Chien"); // Méthode en cache au niveau serveur pstmt.executeUpdate (); } catch (SQLException e) { e.printStackTrace(); return; } } }