
//this code is not working! please help me to find error. thanks.
<%@ page import="java.sql.*" %>
<%
Connection con=null;
String user=request.getParameter("userid");
session.putValue("userid",user);
String pwd=request.getParameter("pwd");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
con = DriverManager.getConnection("jdbc:odbc:mydb","","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from table1 where userid='"+user+"' and pwd='"+pwd+"'");
int i=0;
while(rs.next()){
i++;
}
if(i>0){
out.println("welcome " +user);
}
else{
response.sendRedirect("login.html");
}
}
catch(Exception e){
System.out.println(e);
}
%>

Follow these steps:
1)Go to the start->Control Panel->Administrative Tools-> data sources.
2)Click Add button and select the driver Microsoft Access Driver(*.mdb).
3)After selecting the driver, click finish button.
4)Then give Data Source Name and click ok button.
5)Your DSN will get created.
6) Restart your server and run your jsp/servlet code