输出不正确,将Class.forName显示为输出

时间:2016-09-11 08:48:19

标签: java mysql jsp

代码显示输出为“com.mysql.jdbc.Driver” 是因为数据库还是什么?我在这里使用JSP并尝试验证用户的详细信息。

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%@page import="java.sql.*"%>
        <%@page import="javax.sql.*" %>
        <%
        try{
        String username=request.getParameter("user");
        String password=request.getParameter("pwd");
        Class.forName("com.mysql.jdbc.Driver");
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3307/tyit1", "root", "sphinx1");
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery("select * from login where username='"+username+"' and password='"+password+"'");

        if(rs.next())
                       {
            String user=rs.getString("username");
            String pass=rs.getString("password");

        }
               else{
               out.print("Invalid Credentials!");
               }


        }
        catch(Exception e)
                               {
        out.println(e.getMessage());
        }

        %>
    </body>
</html>

0 个答案:

没有答案