A exception é a seguinte:
javax.servlet.ServletException: 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 ‘where numeroconta= 11’ at line 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.adicionamovimentos_jsp._jspService(org.apache.jsp.adicionamovimentos_jsp:109)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: 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 ‘where numeroconta= 11’ at line 1
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2974)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1599)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1694)
com.mysql.jdbc.Connection.execSQL(Connection.java:3002)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1129)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1358)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1275)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1260)
org.apache.jsp.adicionamovimentos_jsp._jspService(org.apache.jsp.adicionamovimentos_jsp:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
O que quero fazer é o seguinte: Receber um parâmetro de um formulário contendo o NUMERODACONTA dentro de uma variável e aplicando do seguinte modo:
String d = request.getParameter(“data”);
String v = request.getParameter(“valor”);
String numeroconta = request.getParameter(“numeroconta”);
Connection c = DriverManager
.getConnection("jdbc:mysql://localhost:3306/lucas?user=root&password=123");
PreparedStatement ps = c
.prepareStatement("insert into movimento (data,valor) values(?,?) where movimento.numeroconta = " + numeroconta);
int ano, mes, dia;
out.print("Data :" + d);
ps.setDate(1, new java.sql.Date(2006, 06, 01));
ps.setFloat(2, new Float(v));
//ps.setInt(3, Integer.parseInt(numeroconta));
int rowsAffected = ps.executeUpdate();
if (rowsAffected == 1) {
ps.close();
c.close();
Desde já agradeço.