Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

packageproject1; importjava.io.IOException; import java.io.PrintWriter; importja

ID: 3608851 • Letter: P

Question

packageproject1;

importjava.io.IOException;
import java.io.PrintWriter;

importjavax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Servlet1extends HttpServlet {
    private static final String CONTENT_TYPE ="text/html; charset=windows-1256";

    publicvoid init(ServletConfig config) throws ServletException {
        super.init(config);
    }
     boolean LogIn(String e_mail,Stringpassword) throws SQLException,IOException
         {
          
               try{
                  
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    Connection   con =DriverManager.getConnection("jdbc:odbc:MSAccessDatabase","","");
                    Statement st= con.createStatement();
                    String sql="SELECT user_mail AND user_password FROMuser_data"+"WHERE user_mail="+e_mail+"ANDuser_password="+password;
                    ResultSet result=st.executeQuery(sql);
                     st.close();
                     result.close();
                     con.close();
                     return true;
                   }
           
           catch (ClassNotFoundException e) {
              
                }
            return false;
         }

Explanation / Answer

Dear.... while connecting the MSAccessDatabase the following code mayuse. static
{     try            {               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            }               catch(ClassNotFoundException e)                {
                  System.err.println("JdbcOdbc Bridge Driver not found!");
               }
           }
public static Connection getAccessDBConnection(String filename)throws SQLException {       filename = filename.replace('','/').trim();         String databaseURL= accessDBURLPrefix + filename + accessDBURLSuffix;         returnDriverManager.getConnection(databaseURL, "", "");     } and while runing this progem, we may configure the paramvalues in web.xml file. I hope it is usefull toyou.