try
{
Connection con = null;
Statement st=null;
Statement st1=null;
int i;
String connectionURL = "jdbc:mysql://localhost:3306/your db name";
String g1=request.getParameter("Login");
String s1=request.getParameter("uname");
String s2=request.getParameter("pass");
if(g1!=null)
{
String sql1="select * from userdetails where uname='"+s1+"' and pass='"+s2+"'";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection =DriverManager.getConnection(connectionURL,"root","root");
st=connection.createStatement();
ResultSet rs=st.executeQuery(sql1);
if(rs.next())
{
response.sendRedirect("UserHome.jsp");
}
else
{
out.println("<html><body><script type=\"text/javascript\">");
out.println("confirm('INVALID USERNAME or PASSWORD');");
out.println("</script></body></html>");
}
}
}
catch(Exception e)
{
out.println(e);
}