AntoniRyszard656
asked on
SQL Update exception?
Hello,
When I tomcat run this preparedstatement an exception is thrown in the java tomcat window. Though I cannot find the exception in the log files.
Could I ask if I am correct in using statement.executeUpdate() ?
Or any there is any other small errors?
Thanks
PreparedStatement statement = null;
try{
conn = (Connection)source.getConn ection();
String sql = "UPDATE user SET firstname=? lastname=? email=? telno=? expertise=? WHERE email=?";
statement = conn.prepareStatement(sql) ;
statement.setString(1,req. getParamet er("firstn ame"));
statement.setString(2,req. getParamet er("lastna me"));
statement.setString(3,req. getParamet er("email" ));
statement.setString(4,req. getParamet er("telno" ));
statement.setString(5,req. getParamet er("expert ise"));
statement.setString(6,req. getParamet er("email" ));
int rowsChanged = statement.executeUpdate();
if(rowsChanged > 0){
return true;
}
}
catch(SQLException e){
e.printStackTrace();
}
When I tomcat run this preparedstatement an exception is thrown in the java tomcat window. Though I cannot find the exception in the log files.
Could I ask if I am correct in using statement.executeUpdate() ?
Or any there is any other small errors?
Thanks
PreparedStatement statement = null;
try{
conn = (Connection)source.getConn
String sql = "UPDATE user SET firstname=? lastname=? email=? telno=? expertise=? WHERE email=?";
statement = conn.prepareStatement(sql)
statement.setString(1,req.
statement.setString(2,req.
statement.setString(3,req.
statement.setString(4,req.
statement.setString(5,req.
statement.setString(6,req.
int rowsChanged = statement.executeUpdate();
if(rowsChanged > 0){
return true;
}
}
catch(SQLException e){
e.printStackTrace();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need commas in your sql statement.
ASKER
Thank you,
I would also be interested to ask, if you could explain the use of the ejb?
I wondered if the ejb was similar to hibernate, and helped in storing and retrieving objects from the database? And why text-books often dislike the ejb?
Thanks
I would also be interested to ask, if you could explain the use of the ejb?
I wondered if the ejb was similar to hibernate, and helped in storing and retrieving objects from the database? And why text-books often dislike the ejb?
Thanks
>>I would also be interested to ask, if you could explain the use of the ejb?
Perhaps you would like to open a new question and close this one :)
hongjun
Perhaps you would like to open a new question and close this one :)
hongjun
ASKER
I think I will keep the question open shortly incase others was the add.
You may wish to read these
http://www.javaworld.com/javaworld/jw-12-2001/jw-1207-yesnoejb.html
http://www.comptechdoc.org/docs/kanti/ejb/whenejb.html
hongjun
http://www.javaworld.com/javaworld/jw-12-2001/jw-1207-yesnoejb.html
http://www.comptechdoc.org/docs/kanti/ejb/whenejb.html
hongjun