Pessoal por alguma razão estou tendo o erro abaixo, é um simples insert... alguem pode me ajudar?abs
GRAVE: Servlet.service() for servlet AdicionaProdutoServlet threw exception
java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, preco, disponivel, img) values ('y', 'y', 12.0, 1, 'asd')' at line 1
at br.com.adminweb.dao.ProdutoDAO.grava(ProdutoDAO.java:33)
at br.com.adminweb.servlets.AdicionaProdutoServlet.service(AdicionaProdutoServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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:102)
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.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, preco, disponivel, img) values ('y', 'y', 12.0, 1, 'asd')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362)
at br.com.adminweb.dao.ProdutoDAO.grava(ProdutoDAO.java:30)
... 14 more
public void grava(Produto produto) {
//String query = "INSERT INTO produto (nome, desc, preco, disponivel, img) VALUES (?, ?, ?, ?, ?)";
String query = "insert into produto (nome, desc, preco, disponivel, img) values (?, ?, ?, ?, ?)";
try {
PreparedStatement stmt = connection.prepareStatement(query);
stmt.setString(1, produto.getNome());
stmt.setString(2, produto.getDesc());
stmt.setDouble(3, produto.getPreco());
stmt.setBoolean(4, produto.isDisp());
stmt.setString(5, "asd");
stmt.execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
Todos os campos estao criados na tabela, tenho um campo id também mais ele é AI.