1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver chargé");
Connection cnnx = DriverManager.getConnection("jdbc:mysql://localhost:3306/universite","root","");//Connexion à la BD
System.out.println("Connexion bien établie");
Statement state = cnnx.createStatement();
String filenom = (String)request.getParameter("matiere");
Blob fichier=(Blob)request.getAttribute("fich");//pour recupérer le fichier depuis le champs file
state.executeQuery("INSERT INTO corrigetype (nom,fichier)VALUES ('" +filenom+"','" +fichier+"')");//stocker le fichier dans la BD
}
catch(Exception e){
e.printStackTrace();} |
Partager