Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
help me i am hosting java web database application first time.The code which where running on netbeans it is not working there.I use the code as follows:
Java
   <%
           
             String un=request.getParameter("username");
             String pass=request.getParameter("password");
            Connection conn = null;
            boolean i=false;
            int flag=0;
      try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(ClassNotFoundException e) {
      out.println("exceptoin 0");
}
// connect to DB
try{
conn = DriverManager.getConnection("jdbc:odbc:SIM","sanket","raut8989");
    } 
           catch(SQLException se1) {
out.println("exception 1");
}
//out.println("connection is successful!!!");
       
        try{
         
          
            Statement stmt = conn.createStatement();
            ResultSet rs=stmt.executeQuery("select * from authen");
            
            while(rs.next())
            {
                if(rs.getString(1).equals(un.trim()) && rs.getString(2).equals(pass.trim()))
                               {
                                i=true;
                                }
               
             if(i==true)
            {
               session.setAttribute("username",un);
               flag=1;
               RequestDispatcher dispatcher =
         request.getRequestDispatcher("home.jsp");
      if (dispatcher != null)
         dispatcher.forward(request, response);
               
            }
          else
           {    flag=0;
               out.println("Wromg username password");
           }
           
            }
        }  
         catch(SQLException s5)
         {
             out.println(s5);
         } 
        %>
Posted
Updated 2-Mar-11 1:27am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900