Home > Back-end >  HTTP Status 500 - Internal Server Error
HTTP Status 500 - Internal Server Error

Time:09-27

Login error, bosses help
The code is as follows:
<% @ page contentType="text/HTML. Charset=GB2312 "% & gt;
<% @ page import="Java. SQL. *" % & gt;
<% % @ page language="Java" & gt;
<% @ page import="Java. Util. *" % & gt;


<br/>Authentication <br/>

<body bgcolor="# FFFFFF" & gt;
<% request. The setCharacterEncoding (" GBK ");
String user=request. The getParameter (" username ");
String PWD=request. The getParameter (" password ");
String sel=request. The getParameter (" select ");
The String url="JDBC: odbc: yuqingpeng";
String userName="sa";
String password="123456";
The String URL="";
String SQL="";
Connection conn=null;
Try {
Class.forname (" sun. JDBC. Odbc. JdbcOdbcDriver ");
}
The catch (a ClassNotFoundException e)
{
Out.println (" abnormal "when loading driver class);
}
Try {
Conn=DriverManager. GetConnection (url, userName, password);
//create the Statement Statement
}
The catch (SQLException e)
{
Out.println (" appear in the process of the connect to the database SQL exceptions & lt; Br>" );
}
The Statement STMT=conn. CreateStatement ();
If (sel) equals (" student ")) {
SQL="SELECT * FROM student where stu_id='" + user +"' and password='" + PWD + "' ";
URL="student. JSP";
The ResultSet rs=STMT. ExecuteQuery (SQL);
{if (rs. Next ())
String a=rs. Get String (" name ");
Request. GetSession (true);
Session. SetAttribute (" name ", a);
Session. SetAttribute (" id ", the user);
The response. SendRedirect (URL); }
The else
Response. SendRedirect (" error. JSP ");
}

Else if (sel) equals (" admin ")) {
SQL="SELECT * FROM admin where admin_id='" + user +"' and password='" + PWD + "' ";
URL="admin. JSP";
The ResultSet rs=STMT. ExecuteQuery (SQL);
{if (rs. Next ())
Request. GetSession (true);
Session. SetAttribute (" id ", the user);
The response. SendRedirect (URL); }
The else
Response. SendRedirect (" error. JSP ");
}

//use the executeQuery execute SQL query statement

% & gt;


CodePudding user response:

The Statement STMT=conn. CreateStatement (); This line to an empty instruction exception!
You after the conn initialization, print the conn object, see if there are any problems?
  • Related