Home > Back-end >  Modify data in a mysql, always prompt error code, great job right away, please help
Modify data in a mysql, always prompt error code, great job right away, please help

Time:09-22

Has been submitted to the coding errors, beginners can't understand, a great god help

1. The JSP
<% @ page language="Java" import="Java. Util. *" contentType="text/HTML. Charset=gb2312 "% & gt;
<% @ page import="Java. SQL. *" % & gt;


The user information & lt;/title> <br/></head> <br/><% request. The setCharacterEncoding (" GBK "); <br/>The response. SetCharacterEncoding (" GBK "); <br/>//String userid=request. The getParameter (" userid "); <br/>String userid=new String (request. The getParameter (" userid "). GetBytes (" ISO8859_1 "), "utf-8"); <br/>System. The out. Print (userid); <br/>Connection conn=null; <br/>The Statement stat=null; <br/>ResultSet rs=null; <br/>Class.forName("com.mysql.jdbc.Driver"); <br/>The String url="JDBC: mysql://localhost: 3306/zhbit"; <br/>String user="root"; <br/>String password="ax191823503"; <br/>Conn=DriverManager. GetConnection (url, user, password); <br/>The stat=conn. CreateStatement (); <br/>Rs=stat. ExecuteQuery (" select * from the user where userid='" + userid + "' "); <br/>%> <br/><Br> <br/><The h2 & gt; The user information & lt;/h2 & gt; <Hr> <br/><Br> <br/><H3 & gt; To modify the user information below & lt;/h3 & gt; <br/><Table width="450" border="100" cellSpacing=1 style="font - size: 15 pt; Border: dashed 1 pt "& gt; <br/><Tr> <br/><td> User id</td> <br/><td> Name & lt;/td> <br/><td> Password & lt;/td> <br/></tr> <br/><% <br/>While (rs), next ()) <br/>{<br/>Out. Print (" & lt; Tr>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" userid ") + "& lt;/td>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" name ") + "& lt;/td>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" password ") + "& lt;/td>" ); <br/>Out. Print (" & lt;/tr>" ); <br/>%> <br/></table> <br/><Br> <br/><H3 & gt; The user information for the change: & lt;/h3 & gt; <br/><The form action="2. JSP" method="post" onSubmit="return the validate ()" & gt; <br/><H4 & gt; User id: & lt; Input type="text" name="userid" value="https://bbs.csdn.net/topics/<%=rs. Get string (" userid") % & gt;" Title="username cannot change" readonly="readonly" & gt; </input> <Br> </h4 & gt; <br/><H4 & gt; Name: & lt; Input type="text" name="name" title="password cannot be empty" onClick="return checkName (name)" & gt; </input> <Br> </h4 & gt; <br/><H4 & gt; Password: & lt; Input type="text" name="password" title="age can not be empty" & gt; </input> <Br> </h4 & gt; <br/><Input type="submit" value="https://bbs.csdn.net/topics/to modify"/& gt; <br/></form> <br/><Br> <br/>& lt; H3 & gt; <Add information returned a href=https://bbs.csdn.net/topics/addStuInfo.jsp> page </a> </h3> <br/><H3 & gt; <A href=https://bbs.csdn.net/topics/showInfo.jsp> return information query page </a> </h3> <br/><% <br/>} <br/>%> <br/><% <br/>If (rs!=null) <br/>{<br/>Rs. The close (); <br/>Rs=null; <br/>} <br/>If (stat!=null) <br/>{<br/>Stat. The close (); <br/>The stat=null; <br/>} <br/>If (conn!=null) <br/>{<br/>conn.close(); <br/>Conn=null; <br/>} <br/>%> <br/><br/></body> <br/></html> <br/><br/>2. The JSP <br/><% @ page language="Java" import="Java. Util. *" contentType="text/HTML. Charset=gb2312 "% & gt; <br/><% @ page import="Java. SQL. *" % & gt; <br/><Html> <head> <br/><title> Modify the page & lt;/title> <br/></head> <br/><% request. The setCharacterEncoding (" GBK "); <br/>The response. SetCharacterEncoding (" GBK "); <br/>String userid1=request. The getParameter (" userid "); <br/>String name1=request. The getParameter (" name "); <br/>String password1=request. The getParameter (" password "); <br/>Connection conn=null; <br/>The Statement stat=null; <br/>Class.forName("com.mysql.jdbc.Driver"); <br/>The String url="JDBC: mysql://localhost: 3306/zhbit"; <br/>String user="root"; <br/>String password="ax191823503"; <br/>Conn=DriverManager. GetConnection (url, user, password); <br/>The stat=conn. CreateStatement (); <br/>Stat. The execute (" update user set userid='" + userid1 + "', name='" + + "name1", "='" + + "password1 'where userid='" + userid1 + "'"); <br/>The ResultSet rs=stat. ExecuteQuery (" select * from the user where userid='" + userid1 + "' "); <br/>%> <br/><Br> <br/><H3 & gt; Modify the success! </h3 & gt; <br/><Br> <br/><H3 & gt; The modified information is: & lt;/h3 & gt; <br/><Hr> <br/><Br> <br/><Br> <br/><Table width="450" border="100" cellSpacing=1 style="font - size: 15 pt; Border: dashed 1 pt "& gt; <br/><Tr> <br/><td> User id</td> <br/><td> The user name & lt;/td> <br/><td> Password & lt;/td> <br/></tr> <br/><% <br/>While (rs), next ()) <br/>{<br/>Out. Print (" & lt; Tr>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" userid ") + "& lt;/td>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" name ") + "& lt;/td>" ); <br/>Out. Print (" & lt; Td>" + rs. Get string (" password ") + "& lt;/td>" ); <br/>Out. Print (" & lt;/tr>" ); <br/>} <br/>%> <br/></table> <br/><Br> <br/><Br> <br/><H3 & gt; <Add information returned a href=https://bbs.csdn.net/topics/usermanage.jsp> page </a> </h3> <br/><% <br/>If (rs!=null) <br/>{<br/>Rs. The close (); <br/>Rs=null; <br/>} <br/>If (stat!=null) <br/>{<br/>Stat. The close (); <br/>The stat=null; <br/>} <br/>If (conn!=null) <br/>{<br/>conn.close(); <br/>nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/Backend/21339.html" target="_blank" style="color:#999">https//www.codepudding.com/Backend/21339.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/Backend/21338.html'>SpringBoot Thymeleaf: how to open a new window, and the value in the past?</a></div> <div class="detail-arr-right">Next:<a href='/Backend/21340.html'>JSP on the web page display garbled words will submit your work in a great god for help</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=Web+development' target='_blank'>Web development</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>