2 qq 29017467 qq_29017467 于 2015.06.22 21:35 提问

Java web报错。我换了个数据库就报错了

用以前的数据库是对的,换了个数据库他就报错了。图片说明
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ page import="java.sql.*" %>



学生用户登录模块

学生信息系统学生用户登录

账号:
密码:





<%

String account=request.getParameter("account");
if(account==null){account="";}
byte b[]=account.getBytes("ISO-8859-1");
account=new String(b);

 String secret=request.getParameter("secret");
 if(secret==null){secret="";}
 byte c[]=secret.getBytes("ISO-8859-1");
 secret=new String(c);

 Connection con=null;
 Statement sql=null;
 ResultSet rs=null;
 try{
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     }
 catch(ClassNotFoundException event){}
 try
    {                   
       con=DriverManager.getConnection("jdbc:odbc:manage","","");
       sql=con.createStatement();
       String condition="SELECT*FROM verify WHERE 账号="+"'"+account+"'";
       rs=sql.executeQuery(condition);
       while(rs.next())
       {
            String n=rs.getString("账号");
            String s=rs.getString("密码");
            if(account.equals(n)&&secret.equals(s))
            {
                session.setAttribute("account",account);
                session.setAttribute("secret",secret);
                out.println("检测成功。");
                String s1=response.encodeRedirectUrl("studentCX.jsp");
                response.sendRedirect(s1);
             }
        }
        if(!(session.isNew()))
             {
                 out.print("<BR>您输入的用户民或密码不正确"+account+":"+secret);
             }
        }
        catch(SQLException e1){}
        con.close();

%>

返回主页)



1个回答

qq_29017467
qq_29017467   2015.06.22 21:36

不好意思,发错代码了。?
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>



学生用户查询模块

学生信息系统学生用户查询

输入学生的学号:


<%
String studentNumber=request.getParameter("number");
if(studentNumber==null){studentNumber="?";}
byte b[]= studentNumber.getBytes("ISO-8859-1");
studentNumber=new String(b);
Statement sql=null;
ResultSet rs=null;
Connection con=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){out.print(e);}
try
{
con=DriverManager.getConnection("jdbc:odbc:manage","","");
sql=con.createStatement();
String condition="SELECT * FROM 基本信息 WHERE 学号="+"'"+studentNumber+"'";
rs=sql.executeQuery(condition);
}
catch(SQLException e){out.print(e);}
try{
out.print("

");
out.print("");
out.print("");
while(rs.next())
{
out.print("");
String number=rs.getString(1);
out.print("");
String Name=rs.getString(2);
out.print("");
String Sex=rs.getString(3);
out.print("");
String Age=rs.getString(4);
out.print("");
String Major=rs.getString(5);
out.print("");
String Grade=rs.getString(6);
out.print("");
String Address=rs.getString(7);
out.print("");
out.print("");
}
out.print("
"+"学号");
out.print("
"+"姓名");
out.print("
"+"性别");
out.print("
"+"年龄");
out.print("
"+"年级");
out.print("
"+"专业");
out.print("
"+"家庭住址");
out.print("
"+number+""+Name+""+Sex+""+Age+""+Major+""+Grade+""+Address+"
");
}
catch(SQLException e1) {}
%>

返回主页

Csdn user default icon
上传中...
上传图片
插入图片