错误Unknown column 'root' in 'where clause'
try{InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/xyrcw");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String query = "select * from administrator where admin_name="+name;
ResultSet rs = stmt.executeQuery(query);
if(rs ==null)
{
out.print("<script>msg2();</script>");
}
while(rs.next()){
String str=rs.getString("admin_password");
if (!pwd.equals(str))
{
out.print("<script>msg2();</script>");
}
}
int id=rs.getInt("admin_id");
session.setAttribute("adminId",id);
session.setAttribute("adminName",name);
session.setAttribute("adminPwd",pwd);
query = "select * from admin_login_statistics order by admin_login_statistics_id desc;";
rs = stmt.executeQuery(query);
int num_results = rs.getRow();
for ( int i=0 ; i<num_results;i++)
{
while(rs.next()){
if(i>100)
{
query = "delete from admin_login_statistics where admin_login_statistics_id="+rs.getInt("admin_login_statistics_id");
stmt.executeUpdate(query);
}
}
}
HttpServletRequest req=null;
String ip=req.getRemoteAddr();
String date=new java.sql.Date(new java.util.Date().getTime()).toString();
query = "insert into admin_login_statistics (admin_name,admin_login_date,admin_login_ip,admin_logout_date)values('"+name+"','"+date+"','"+ip+"','"+date+"')";
stmt.executeUpdate(query);
response.sendRedirect("index.jsp");
}
catch(Exception ex){
out.print("<script>msg1();</script>");
ex.printStackTrace();
}
输入账号root和密码时出现错误Unknown column 'root' in 'where clause',请问怎么回事?