连接数据库进行修改的代码也有问题,我试过很多方法都是不行 stmt.executeUpdate("updata students set password="+password3+"where id="+uid); 报错是 org.apache.jasper.JasperException: Exception in JSP: /alterps.jsp:3431: String url="jdbc:mysql://localhost/jk?user=root&password=root"; 32: Connection conn = DriverManager.getConnection(url); 33: Statement stmt=conn.createStatement(); 34: stmt.executeUpdate("updata studends set password="+pd+" where id="+uid); 35: 36: } 37: else Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause 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 'updata studends set password=123 where id=200404660' at line 1 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.alterps_jsp._jspService(alterps_jsp.java:111) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause com.mysql.jdbc.exceptions.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 'updata studends set password=123 where id=200404660' at line 1 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2938) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1601) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1710) com.mysql.jdbc.Connection.execSQL(Connection.java:2430) com.mysql.jdbc.Statement.executeUpdate(Statement.java:1374) com.mysql.jdbc.Statement.executeUpdate(Statement.java:1290) org.apache.jsp.alterps_jsp._jspService(alterps_jsp.java:81) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
stmt.executeUpdate("updata students set password="+password3+"where id="+uid); 少了单引号吧~~~~ 你的password应该是varchar2吧???那就应该是stmt.executeUpdate("updata students set password='"+password3+"' where id="+uid);你可以在下面把你这句打出来看看是什么,比如: String sql="updata students set password="+password3+"where id="+uid; stmt.executeUpdate(sql); System.out.println(sql);
if(password1.equals(upd)||password1==upd)
把错误代码贴出来。
stmt.executeUpdate("updata students set password="+password3+"where id="+uid); 报错是
org.apache.jasper.JasperException: Exception in JSP: /alterps.jsp:3431: String url="jdbc:mysql://localhost/jk?user=root&password=root";
32: Connection conn = DriverManager.getConnection(url);
33: Statement stmt=conn.createStatement();
34: stmt.executeUpdate("updata studends set password="+pd+" where id="+uid);
35:
36: }
37: else
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause 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 'updata studends set password=123 where id=200404660' at line 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.alterps_jsp._jspService(alterps_jsp.java:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause com.mysql.jdbc.exceptions.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 'updata studends set password=123 where id=200404660' at line 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2938)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1601)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1710)
com.mysql.jdbc.Connection.execSQL(Connection.java:2430)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1374)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1290)
org.apache.jsp.alterps_jsp._jspService(alterps_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
少了单引号吧~~~~
你的password应该是varchar2吧???那就应该是stmt.executeUpdate("updata students set password='"+password3+"' where id="+uid);你可以在下面把你这句打出来看看是什么,比如:
String sql="updata students set password="+password3+"where id="+uid;
stmt.executeUpdate(sql);
System.out.println(sql);
password 是int 类型