0

Hi i new to develop wes app in JSP I am here using the access database. I have configured the .mdb datasource for the web app. When i am trying to access database i am getting the error java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

When enter my username and password the submit the form , This time it generates the error.

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);
}
%>

Can you please findout where i am doing wrong ?

Pranav MS
  • 2,235
  • 2
  • 23
  • 50
  • 3
    The slow, buggy and unreliable JDBC/ODBC bridge was removed in Java 8 –  Feb 16 '17 at 13:49
  • 2
    Unrelated, but: **never** create connections like that in the JSP page. Use a proper connection pool. And never use Java code like that in a JSP page. Use proper JSTL Tags and a backing bean/servlet to provide the data –  Feb 16 '17 at 13:49
  • This project was previously working fine. Now I want to make it better by adding some new modules to it. Please guide me to achieve the best outcome with renovated ( the older one with new modules ) version of the project. – Pranav MS Feb 16 '17 at 14:01
  • Have you application display `System.getProperty("java.version")`. What does it show? – Gord Thompson Feb 16 '17 at 15:07
  • @GordThompson it is not showing anything. – Pranav MS Feb 16 '17 at 15:29

0 Answers0