ResultSet rs = stmt.executeQuery(sql); 出现错误
<body><divalign=center><%//获取用户名StringsUserName=request.getParameter("txtUserName");/...
<body>
<div align=center>
<%
//获取用户名
String sUserName = request.getParameter ( "txtUserName" );
//获取密码
String sPasswd = request.getParameter ( "txtPassword" );
//登记JDBC驱动程序
Class.forName ( "org.gjt.mm.mysql.Driver" ).newInstance ( );
//连接参数与Access不同
String url = "jdbc:mysql://localhost/school";
//建立连接
Connection connection = DriverManager.getConnection ( url, "root",
"admin" );
//SQL语句
String sql = "select * from student where username='" + sUserName + "' and userpwd = '" + sPasswd + "'";
Statement stmt = connection.createStatement ( );
ResultSet rs = stmt.executeQuery(sql);
if ( rs.next ( ) )
{
out.println ( "登录成功!" );
} else
//否则登录失败
{
out.println ( "用户名不存在或密码错误!" );
}
提示ResultSet rs = stmt.executeQuery(sql); 错误 展开
<div align=center>
<%
//获取用户名
String sUserName = request.getParameter ( "txtUserName" );
//获取密码
String sPasswd = request.getParameter ( "txtPassword" );
//登记JDBC驱动程序
Class.forName ( "org.gjt.mm.mysql.Driver" ).newInstance ( );
//连接参数与Access不同
String url = "jdbc:mysql://localhost/school";
//建立连接
Connection connection = DriverManager.getConnection ( url, "root",
"admin" );
//SQL语句
String sql = "select * from student where username='" + sUserName + "' and userpwd = '" + sPasswd + "'";
Statement stmt = connection.createStatement ( );
ResultSet rs = stmt.executeQuery(sql);
if ( rs.next ( ) )
{
out.println ( "登录成功!" );
} else
//否则登录失败
{
out.println ( "用户名不存在或密码错误!" );
}
提示ResultSet rs = stmt.executeQuery(sql); 错误 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |