jsp登录页面代码错误。高手帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/30 12:57:59
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java" import="java.sql.*"%>
<html>
<body>
<%
String a,b;
a=request.getparameter("use");
b=request.getparameter("pas");
String c,d;
c="select * from user where username='"+a+"' and password='"+b+"'";
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try
{
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
}
catch(ClassNotFoundException e){}
try{
con=DriverManager.getConnection("jdbc:odbc:cha","","");
sql=con.createStatement();
rs=sql.executeQuery(c);
if (rs.next())
{
response.sendRedirect("main.jsp");
}
else
{
response.sendRedirect("denglu.jsp");
}
}
catch(SQLExceptio

没看出来有什么问题,
把你的错误提示贴出来.

在你的catch(Exception e){}
中写上点输出信息的代码,要不哪儿出错了都不知道.

这里的(P)有没有大写要大写的P request.getparameter("pas");
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");这里好像也有点问题改成这样试试验:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
如果你用的是ACCESS数据库的话,那么后面的那个“”“”就不要了
con=DriverManager.getConnection("jdbc:odbc:cha","","");

其他的好像暂看不出来,如果错误的代码贴出来可能会好一点