SQL语句出错~~请指点

来源:百度知道 编辑:UC知道 时间:2024/05/03 10:38:30
出现的错误代码java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]第 1 行: '=' 附近有语法错误。

源代码:
<%@page contentType="text/html;charset=gb2312"language="java" %>
<%@page import="java.sql.*"%>
<%@include file="include.inc"%>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
Class.forName(CLASSFORNAME);
Connection con=DriverManager.getConnection(SERVER,USER,PWD);
Statement stmt=con.createStatement();
String isCorrect="select * from tb_user where username='"+username+"' and password='"+password+"'";
ResultSet rs=stmt.executeQuery(isCorrect);
if(!rs.next())
{
response.sendRedirect("login.html");
rs.close();
stmt.close();
con.close();
}
//如果登录用户的投票标识为0,则允许用户投票,并

<%@page contentType="text/html;charset=gb2312"language="java" %>
改成
<%@page contentType="text/html;charset=gb2312" language="java" %>

String isCorrect="select * from tb_user where username='"+username+"' and password='"+password+"'";
改成
String isCorrect="select * from tb_user where [username]='"+username+"' and [password]='"+password+"'";

将String isCorrect="select * from tb_user where username='"+username+"' and password='"+password+"'";
改为String isCorrect="select * from tb_user where username=" + username + "and password=" + password;

将stmt.executeQuery("Updata tb_user Set isCheck=isCheck+1 where username='"+username+"'");
改为stmt.executeQuery("Updata tb_user Set isCheck=isCheck+1 w