Com. mysql. jdbc. exceptions. jdbc4.MySQLSyntaxErrorException: Unknown column & #39 ;?????? & #39; in & #39; field list & #39;

Source: Internet
Author: User

Severe: Servlet. service () for servlet jsp threw exception
Com. mysql. jdbc. exceptions. jdbc4.MySQLSyntaxErrorException: Unknown column '?????? 'In' field list'
At sun. reflect. NativeConstructorAccessorImpl. newInstance0 (Native Method)
At sun. reflect. nativeconstruct%cessorimpl. newInstance (nativeconstruct%cessorimpl. java: 39)
At sun. reflect. delegatingconstruct%cessorimpl. newInstance (delegatingconstruct%cessorimpl. java: 27)
At java. lang. reflect. Constructor. newInstance (Constructor. java: 513)
At com. mysql. jdbc. Util. handleNewInstance (Util. java: 406)
At com. mysql. jdbc. Util. getInstance (Util. java: 381)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 1030)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 956)
At com. mysql. jdbc. MysqlIO. checkErrorPacket (MysqlIO. java: 3491)
At com. mysql. jdbc. MysqlIO. checkErrorPacket (MysqlIO. java: 3423)
At com. mysql. jdbc. MysqlIO. sendCommand (MysqlIO. java: 1936)
At com. mysql. jdbc. MysqlIO. sqlQueryDirect (MysqlIO. java: 2060)
At com.mysql.jdbc.ConnectionImpl.exe cSQL (ConnectionImpl. java: 2536)
At com.mysql.jdbc.StatementImpl.exe cuteUpdate (StatementImpl. java: 1564)
At com.mysql.jdbc.StatementImpl.exe cuteUpdate (StatementImpl. java: 1485)
At org. apache. jsp. insert_jsp. _ jspService (insert_jsp.java: 100)
At org. apache. jasper. runtime. HttpJspBase. service (HttpJspBase. java: 70)
At javax. servlet. http. HttpServlet. service (HttpServlet. java: 723)
At org. apache. jasper. servlet. JspServletWrapper. service (JspServletWrapper. java: 388)
At org. apache. jasper. servlet. JspServlet. serviceJspFile (JspServlet. java: 313)
At org. apache. jasper. servlet. JspServlet. service (JspServlet. java: 260)
At javax. servlet. http. HttpServlet. service (HttpServlet. java: 723)
At org. apache. catalina. core. ApplicationFilterChain. internalDoFilter (ApplicationFilterChain. java: 290)
At org. apache. catalina. core. ApplicationFilterChain. doFilter (ApplicationFilterChain. java: 206)
At org. apache. catalina. core. StandardWrapperValve. invoke (StandardWrapperValve. java: 233)
At org. apache. catalina. core. StandardContextValve. invoke (StandardContextValve. java: 191)
At org. apache. catalina. core. StandardHostValve. invoke (StandardHostValve. java: 127)
At org. apache. catalina. valves. ErrorReportValve. invoke (ErrorReportValve. java: 103)
At org. apache. catalina. core. StandardEngineValve. invoke (StandardEngineValve. java: 109)
At org. apache. catalina. connector. CoyoteAdapter. service (CoyoteAdapter. java: 293)
At org. apache. coyote. http11.Http11NioProcessor. process (Http11NioProcessor. java: 891)
At org. apache. coyote. http11.Http11NioProtocol $ Http11ConnectionHandler. process (Http11NioProtocol. java: 750)
At org.apache.tomcat.util.net. NioEndpoint $ SocketProcessor. run (NioEndpoint. java: 2282)
At java. util. concurrent. ThreadPoolExecutor $ Worker. runTask (ThreadPoolExecutor. java: 886)
At java. util. concurrent. ThreadPoolExecutor $ Worker. run (ThreadPoolExecutor. java: 908)
At java. lang. Thread. run (Thread. java: 619)

 

------ Solution --------------------
This error is simple.
From this code, we can see that: String SQL = "INSERT INTO STUDENT VALUES (" + id + "," + name + ")";
If my id = 1, name = adf, then the combined string is
Insert into student values (1, adf) You can try to execute this SQL statement, and it will certainly report an error
The correct syntax should be insert into student values (1, 'fid'); -- the numeric type can be enclosed in single quotes.

So
It should be String SQL = "INSERT INTO STUDENT VALUES (" + id + ", '" + name + "')";
------ Solution --------------------
When you encounter this type of database statement, you can use
System. out. print (SQL); output your statements first, so that you can easily find out if there are any errors.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.