i have modify the code that peter huang wrote and try to run .. but erro occur .. can anyone helps me?
[u]admin_login.jsp</u>
<%@ page import="java.sql.*" %>
<%
String adminId = request.getParameter("admin_id");
String adminPassword = request.getParameter("admin_password");
String driver = "jdbc:mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/sers";
String username = "root";
String password = "123";
String query = "SELECT admin_id,admin_password FROM admin WHERE admin_id = '"+adminId+"' AND admin_password = '"+adminPassword+"'";
Connection con = null;
Statement statement = null;
ResultSet rs = null;
try
{
Class.forName(driver);
con = DriverManager.getConnection(url,username,password) ;
statement = con.createStatement();
rs = statement.executeQuery(query);
if(!rs.next())
{
out.println("<h1>Login Fail</h2>");
}
else
{
out.println("<h1>welcome" + "!</h1>");
}
}
catch(Exception ex)
{
out.println("Error: " + ex.getMessage());
}
finally
{
rs.close();
con.close();
}
%>
|