Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql database update using webservices
    primarykey
    data
    text
    <p>I am using mysql database and workbench, Eclipse IDE, and Tomcat server. I am using MVC model for web services. In HTML form when i supply the username and password, all the details of the user are displayed and when i try to update details for that user it is allowing me to change the details on the webpage. but when i submit the updated details form, then it is showing the below exception and the details are not updated in the database.</p> <h1>Header 1</h1> <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Sapan' in 'where clause' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359) at com.dao.CustomerDAO.updateProduct(CustomerDAO.java:145) at com.dao.UpdateServlet.doPost(UpdateServlet.java:81) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680 </code></pre> <p>I don't where is the issue, but when i try to retrieve the data first it is coming with out any error. and also there is an username 'Sapan' is present in my database. The method that is to update the database is here.</p> <h2>Header 2</h2> <p>public class CustomerDAO extends BaseDAO{</p> <pre><code>public boolean updateProduct(Login login){ try { BaseDAO baseDAO = new BaseDAO(); Connection c = baseDAO.getConnection(); String query = "update test.Customer set City=? ,State=? ,PhoneNumber=? ,Email=? ,Address=? ,ZipCode=? where LoginId="+login.getLoginId(); PreparedStatement preparedStatement = c.prepareStatement(query); preparedStatement.setString(1, login.getCity()); preparedStatement.setString(2, login.getState()); preparedStatement.setString(3, login.getCellnumber()); preparedStatement.setString(4, login.getEmail()); preparedStatement.setString(5, login.getAddress()); preparedStatement.setInt(6, login.getZipcode()); int i = preparedStatement.executeUpdate(); if (i == 1) { System.out.println("Record updated successfully."); } } catch(Exception e) { e.printStackTrace(); } return true; </code></pre> <p>}<br> }</p> <p>Please help me to fing out where is the issue. Thank You in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload