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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<%
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException e){
e.printStackTrace();
}
try{
connection = DriverManager.getConnection("jdbc:mysql://localhost/livre","root","");
}catch(SQLException e){
e.printStackTrace();
}
try{
statement = connection.createStatement();
}catch(SQLException e){
e.printStackTrace();
}
try {
mon_statement.executeUpdate(
"INSERT INTO user " +
"VALUES (" + id + ", '" + nom + "', '" +prenom+ "', '" + email+ "', '" + password +"', " +id_profile +")");
//les valeurs id, nom ... peuvent etre recuperé a partir de champs d'un formulaire par exemple !
//et si tu veux la modif tu met update et ainsi de suite ...
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
%>
</body>
</html> |
Partager