English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have this update function .....everything looks perfect in the function,,,,i have no idea why it returns "Update failed" ...it donst show any error...no SQL error or anthing like that...it just dosnt update....how can I trace the error???......HEELLLLPPPP

so over all i wanna know how to trace eerror when executeUpdate() returns false....tanxxxxxxxxx

here is the code...

public boolean updateCustomerData()
{
//here is coonection and set functions and "try and catch"
if (ps.executeUpdate() != 1){
error="Update failed";
}
else{
isSuccess=true;
this.isCustomerDataLoaded = true;
}
}catch(ClassNotFoundException ex){
error=ex.getMessage();
}catch(SQLException ex){
error=ex.getMessage();
}catch (Exception ex){
error=ex.getMessage();

2006-06-27 18:58:27 · 4 answers · asked by zoha 3 in Computers & Internet Programming & Design

4 answers

Hi, It might be correct... Below is what I assume your code before the if statement.

PreparedStatement ps = con.prepareStatement(
"UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ? ");
ps.setInt(1, 75);
ps.setString(2, "Colombian");
int n = ps.executeUpdate():

Note that when the return value for executeUpdate is 0 , it can mean one of two things: (1) the statement executed was an update statement that affected zero rows, or (2) the statement executed was a DDL statement.

It doesn't necessarily mean it has failed, it might mean nothing has changed. Check if your properties of your sql syntax is correct. Because everything upto here is correct. But 0 can mean two stuff as I mentioned above.

Take care

2006-06-28 02:25:53 · answer #1 · answered by ? 6 · 0 0

Hey Missy!!!

Please send the code of "ps.executeUpdate()" function so that we can see what's going on!!!!!

2006-06-27 19:55:40 · answer #2 · answered by programmer 4 · 0 0

Can u mail me the whole source of that function so that i can help u...
vijji_bdr@yahoo.com

2006-06-27 20:18:11 · answer #3 · answered by vijji_bdr 2 · 0 0

dear
u can study and discuss jsp @


http://www.studyjava.org/jsp/index.htm

2006-06-27 19:15:13 · answer #4 · answered by ihoston 3 · 0 0

fedest.com, questions and answers