1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=null;
if(con!=null){
out.println("connexion etablie");
}
else{
out.println("connexion echouée");
}
String URL ="jdbc:mysql//localhost:8080/personne?user=root";
con = DriverManager.getConnection(URL);
PreparedStatement st = con.prepareStatement("insert into person (nom,prenom) values(name,lastname)");
st.executeUpdate();
con.close();
st.close();
}catch(Exception e){
out.print(e.getMessage());
} |
Partager