<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030" import="java.sql.*"%> Insert title here <% try { String username=new String(request.getParameter("username").getBytes("ISO-8859-1"),"GB18030"); String quanxian2=new String(request.getParameter("quanxian2").getBytes("ISO-8859-1"),"GB18030"); String sql_password="select password from reg where username='"+username+"'"; String password=info.GetRsValue(sql_password); System.out.println(password+"jsp===========password"); Connection con=info.getCon(); // 添加信息的SQL语句 String sql = "update reg set quanxian='"+quanxian2 +"' where username='"+username+"'"; // 获取PreparedStatement PreparedStatement ps = con.prepareStatement(sql); int row = ps.executeUpdate(); ps.executeUpdate(); if(quanxian2.equals("管理员")){ String sql2="insert into login (username,password) values ('" +username+ "','" +password+"')"; int row2=info.GetCount(sql2); }else{ String sql3="delete from login where username='"+username+"'"; info.executeUpdate(sql3); } if(row > 0){ out.println(""); } // 关闭PreparedStatement,释放资源 ps.close(); // 关闭Connection,释放资源 con.close(); } catch (Exception e) { out.print("变更失败!"); e.printStackTrace(); } %>