<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>学生选课系统</title>
<style type="text/css">
<!--
body {
background-image: url(image/bg_002.gif);
}
-->
</style></head>
<body>
<%
String name=(String)request.getParameter("username");
String pass=(String)request.getParameter("userpass");
String s=(String)request.getParameter("userselect");
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String loginNum="0";
session.setAttribute("lnum",loginNum);
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Conneaction conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=xuanke","sa","");
if(s.equals("1"))
{
String sql="select * from student where sId='"+name+"' and sPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="1";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print(name+"登陆成功,页面跳转........");
response.sendRedirect("student/studentIndex.html");
}
else
{
out.print("用户名或密码有误..");
response.sendRedirect("index.jsp");
}
}
if(s.equals("2"))
{
String sql="select * from teacher where tId='"+name+"' and tPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="2";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print(name+"登陆成功,页面跳转........");
response.sendRedirect("teacher/teacherIndex.html");
}
else
{
out.print("用户名或密码有误..");
response.sendRedirect("index.jsp");
}
}
if(s.equals("3"))
{
String sql="select * from admin where aId='"+name+"' and aPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="3";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print("管理员"+name+"登陆成功,页面跳转........");
response.sendRedirect("admin/adminIndex.html");
}
else
{
out.print("用户名或密码有误..");
out.print("<a href=index.jsp>登陆页面</a>");
}
}
}
catch(Exception e){out.print(e);
//response.sendRedirect("index.jsp");
}
%>
</body>
</html>报错内容如下:
An error occurred at line: 15 in the jsp file: /user1/choosecourse/login.jsp
Generated servlet error:
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=xuanke","sa","");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>学生选课系统</title>
<style type="text/css">
<!--
body {
background-image: url(image/bg_002.gif);
}
-->
</style></head>
<body>
<%
String name=(String)request.getParameter("username");
String pass=(String)request.getParameter("userpass");
String s=(String)request.getParameter("userselect");
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String loginNum="0";
session.setAttribute("lnum",loginNum);
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Conneaction conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=xuanke","sa","");
if(s.equals("1"))
{
String sql="select * from student where sId='"+name+"' and sPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="1";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print(name+"登陆成功,页面跳转........");
response.sendRedirect("student/studentIndex.html");
}
else
{
out.print("用户名或密码有误..");
response.sendRedirect("index.jsp");
}
}
if(s.equals("2"))
{
String sql="select * from teacher where tId='"+name+"' and tPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="2";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print(name+"登陆成功,页面跳转........");
response.sendRedirect("teacher/teacherIndex.html");
}
else
{
out.print("用户名或密码有误..");
response.sendRedirect("index.jsp");
}
}
if(s.equals("3"))
{
String sql="select * from admin where aId='"+name+"' and aPass='"+pass+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.next())
{
loginNum="3";
session.setAttribute("lnum",loginNum);
session.setAttribute("name",name);
out.print("管理员"+name+"登陆成功,页面跳转........");
response.sendRedirect("admin/adminIndex.html");
}
else
{
out.print("用户名或密码有误..");
out.print("<a href=index.jsp>登陆页面</a>");
}
}
}
catch(Exception e){out.print(e);
//response.sendRedirect("index.jsp");
}
%>
</body>
</html>报错内容如下:
An error occurred at line: 15 in the jsp file: /user1/choosecourse/login.jsp
Generated servlet error:
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=xuanke","sa","");
解决方案 »
- 问一个struts2多语言的问题
- saveToken防止2次提交的问题
- 请教各位高手一个问题,在weblogic9.0和weblogic9.2中是不是不支持weblogic builder了?
- java循环截取字符串
- JBOSS部署.ear文件,出现错误commons-io.jar which could not be opened, entry ignored
- Eclipse3。1下面怎么正确的安装eclipse插件,俺都快急死了
- 用JAVA代码读取ACCESS数据库中的OLE字段的内容,该怎么写代码?
- 同样的代码application能调用web服务,而applet调用时就出错(内附代码)
- 散分,推站www.ibzoo.com有些有价值的电子书可以下载的
- 内部类可以实现的功能为什么要用内部接口?
- Hibernate两种查询方式
- 我们正学JDBC呢,可是我觉得书讲得太深太少了,请问谁能给我推荐几个介绍这方面的电子书
jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=xuanke","sa",""