impossible de trouver l'erreur
bonjour
j'utilise easyphp pour la base mysql & eclipse pour jsp
j'ai un probléme au niveau de la suppression et édition (modification) dans un table :calim2:
voila la structure de la table
Ncompte nompre banque moypay de type varchar
voila mon code de suppression
Code:
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 82 83 84 85 86 87 88 89
|
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.lang.Integer"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Suppression Client</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<%
String nompre="";
nompre= request.getQueryString();
String tab[]=new String[2];
if(nompre!=null){
tab=nompre.split("/");
request.getSession().setAttribute("Ncompte",tab[1]);
}
String Ncompte="";
String supprimer = (String)request.getSession().getAttribute("supprimer");
if (supprimer=="O"){
Connection connection=null;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
e.printStackTrace();
}
try{
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/banque","root","");
}catch(Exception e){
e.printStackTrace();
}
Ncompte=(String)request.getSession().getAttribute("Ncompte");
String sql="DELETE FROM utilisateur WHERE Ncompte='" +Ncompte+ "'" ;
try {
Statement statement=connection.createStatement();
statement.executeUpdate(sql);
response.sendRedirect("client.jsp");
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try{
connection.close();
}catch (Exception e){
e.printStackTrace();
}
}
request.getSession().setAttribute("supprimer","N");
}
else
request.getSession().setAttribute("supprimer","O");
%>
<div class="BG">
Supprimer Client
</div>
<form action="supprimerClient.jsp" >
<table width ="100%">
<tr>
<td>Nom & prénom</td>
<td><%=tab[1] %></td>
</tr>
<tr>
<td>N° de compte</td>
<td><%=tab[0] %></td>
</tr>
<tr class="BG" width ="150%">
<td colspan="2" width ="100%">
<input type="button" value="Valider" onClick="submit()"/>
<input type="reset" value="Abandonner" style="width: 107px"/>
</td>
</tr>
</table>
</form>
</body>
</html> |
je n'est trouver aucune et a chaque fois aucune suppression ne s'effectue
pour Edition client
Code:
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.lang.Integer"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Modifier Client</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<%
String ncli="";
String nompre="";
String banque="";
String moypay="";
Connection connection=null;
Statement statement;
ResultSet rs ;
String tab[]=new String[0];
tab=request.getQueryString().split("/");
ncli= tab[0];
System.out.println("ncli="+ncli);
if(tab.length>1){
request.getSession().setAttribute("Ncompte",ncli);
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
e.printStackTrace();
}
try{
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/banque","root","");
}catch(Exception e){
e.printStackTrace();
}
String sql="SELECT * FROM utilisateur where Ncompte='"+ncli+"'" ;
try {
statement=connection.createStatement();
rs = statement.executeQuery(sql);
if(rs.next()){
nompre=rs.getString("nompre");
banque=rs.getString("banque");
moypay=rs.getString("moypay");
}
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
connection.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
else{
nompre = request.getParameter("nompre");
System.out.println("nompre="+nompre);
banque = request.getParameter("banque");
System.out.println("banque="+banque);
moypay = request.getParameter("moypay");
System.out.println("moypay="+moypay);
//ncli = (String)request.getSession().getAttribute("Ncompte");
//System.out.println("ncli="+ncli);
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
e.printStackTrace();
}
try{
connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/banque","root","");
}catch(Exception e){
e.printStackTrace();
}
String sql="update utilisateur set nompre='"+nompre+"' and banque='"+banque+"'and moypay='"+moypay+"'" ;
try {
statement=connection.createStatement();
statement.executeUpdate(sql);
response.sendRedirect("client.jsp");
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try{
connection.close();
}catch (Exception e){
e.printStackTrace();
}
}
}
%>
<div class="BG">
<h4>Modifier Client</h4>
</div>
<form>
<table width ="100%">
<tr>
<td><b>nom & prénom</b></td>
<td><input type="text" name="nompre" style="width: 156px" value="<%=nompre%>"/></td>
</tr>
<tr>
<td><b>Banque</b></td>
<td><input type="text" name="banque" style="width: 156px" value="<%=banque%>"/></td>
</tr>
<tr>
<td><b>Moyen de payement</b></td>
<td><input type="text" name="moypay" style="width: 156px" value="<%=moypay%>"/></td>
</tr>
<tr class="BG" width ="150%">
<td colspan="4" width ="100%">
<input type="button" value="Valider" onClick="submit()"/>
<input type="reset" value="Abandonner" style="width: 107px"/>
</td>
</tr>
</table>
</form>
</body>
</html> |
pas de mofication enregister et tout les nompre (nom & prenom ) deviennent nul CAD 0:aie:
pouvez vous me dire quel est ma faute :cry:
merci