NETBEANS 8.2 java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver EXCEPTION

时间:2017-02-16 13:46:56

标签: jsp ms-access jdbc-odbc

我很高兴在 JSP 中开发wes app我在这里使用access数据库。我已经为Web应用程序配置了.mdb数据源。当我尝试访问数据库时,我收到错误java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

输入我的用户名和密码时,请提交表单,这次会产生错误。

AdminLogin.jsp

<form name="Login" method=get action="AdminLoginRes.jsp">

 username :- <input type="text" name="T1" size="24">

Password :-  <input type="password" name="T2" size="23">

 <input type="submit" value="Submit" name="B1">

AdminLoginRes.jsp

<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>

<%!
String un ="";
String pw = "";
int count = 1;
un = request.getParameter("T1");
pw = request.getParameter("T2");



try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:Stock");

            Statement st = con.createStatement();
            ResultSet rs =st.executeQuery("SELECT * FROM Admin");

            while(rs.next())
            {
            if(un.equals(rs.getString(1)) && pw.equals(rs.getString(2)))
                {
                count = 0;
                 break;
                 }
        else
                 count = 1;
             }
        if (count == 0)
        {
        response.sendRedirect("AdminView.jsp?un="+un+"&pass="+pw);
        }
        else
        {
        response.sendRedirect("AdminLogin.jsp?er=Invalid Username or Password! Try Again... ");
        }
}
catch(Exception e)
{
out.println(e);
}
%>

你能找到我做错的地方吗?

0 个答案:

没有答案