Link to home
Start Free TrialLog in
Avatar of AntoniRyszard656
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.getConnection();

         String sql = "UPDATE user SET firstname=? lastname=? email=? telno=? expertise=? WHERE email=?";

         statement = conn.prepareStatement(sql);
         statement.setString(1,req.getParameter("firstname"));
         statement.setString(2,req.getParameter("lastname"));
         statement.setString(3,req.getParameter("email"));
         statement.setString(4,req.getParameter("telno"));
         statement.setString(5,req.getParameter("expertise"));
         statement.setString(6,req.getParameter("email"));
         int rowsChanged = statement.executeUpdate();

         if(rowsChanged > 0){
            return true;
         }
      }
      catch(SQLException e){
         e.printStackTrace();
      }
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You need commas in your sql statement.
Avatar of AntoniRyszard656
AntoniRyszard656

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?
Perhaps you would like to open a new question and close this one :)


hongjun
I think I will keep the question open shortly incase others was the add.