Bonsoir,

Premierement, désolé si je me trompe d'endroit pour poster ...
J'expose mon probleme, j'ai un projet a faire en java. Programmation web en page JSP, sous linux (LinuxMint/Debian).
Je m'attaque pour intégrer un élément dans ma base de donné, grace a un formulaire. Je n'ai aucune erreur, cependant mon code ne marche pas. J'ai beau chercher, je ne trouve pas mon erreur.
J'ai bien installer je jar. (jdbc).
Voici le code de la JSP. Je sais que c'est ignoble de mettre le code java dans la JSP, mais, je le mettrais dans la servlet quand je serais un peut plus sûr de moi, car, je n'ai jamais fais de mysql, et encore moins de java.
Je suis ouvert à toute remarque.
Cordialement, H.

Code jsp : Sélectionner tout - Visualiser dans une fenêtre à part
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
 
<html>  
<head>  
<title>Read from mySQL Database</title>  
</head>  
 
<body>  
<FORM action="InsertFormulaire.jsp" method="get">
    <TABLE style="background-color: #ECE5B6;" WIDTH="30%" >
         <TR>
              <TH width="50%">Name</TH>
                  <TD width="50%"><INPUT TYPE="text" NAME="name"></TD>
          </tr>
          <TR>
             <TH width="50%">Firstname</TH>
                 <TD width="50%"><INPUT TYPE="text" NAME="pre"></TD>
          </tr>
                  <TR>
              <TH></TH>
                  <TD width="50%"><INPUT TYPE="submit" VALUE="submit"></TD>
          </tr>
   </TABLE>
<%
   String name = request.getParameter("name");
   String prename = request.getParameter("pre");
 
   /* Create string of connection url within specified 
   format with machine name, 
    port number and database name. Here machine name id 
    localhost and database name is student. */
    String connectionURL = "jdbc:mysql://localhost:3306/test_lucas_bdd";
          // declare a connection by using Connection interface 
    Connection connection = null;
        // declare object of Statement interface that uses for 
    
     PreparedStatement pstatement = null;
         // Load JBBC driver "com.mysql.jdbc.Driver"
     Class.forName("com.mysql.jdbc.Driver").newInstance();
 
     
         // check if the text box is empty
 
                         // check if the text box having only blank spaces
 
                         try {
              /* Create a connection by using getConnection()
              method that takes parameters of string type 
              connection url, user name and password to connect 
                to database. */
              connection = DriverManager.getConnection(connectionURL, "root", "eLiqyboz#4piG");
                            // sql query to insert values in the secified table.
              String queryString ="INSERT INTO 'Personne' ('Nom','Prenom') VALUES (?, ?,)";
                      /* createStatement() is used for create statement
              object that is used for 
                sending sql statements to the specified database. */
              pstatement = connection.prepareStatement(queryString);
                          
              pstatement.setString(1, name);
              pstatement.setString(2, prename);
              
              pstatement.executeUpdate();
              
                          } catch (Exception e) {
              e.printStackTrace();
                          }
              finally {
                // close all the connections.
                pstatement.close();
                connection.close();
            }
           
                         
%>
  </FORM>
 </body> 
</html>