Hi can somebody help me i am new to developing. ADD the new record to the existing database table at the end of all rows.Something like registration form details.

<%@page import="java.sql.*" %>

<%
String fisname=request.getParameter("firstname");
String lstname=request.getParameter("lastname");
String sex=request.getParameter("gender");
try
{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:Bharath");
    Statement st=con.createStatement();
    DataInputStream din=new DataInputStream(System.in);
    while(rs.afterlast())
    {
        int count=st.executeUpdate("insert into registeredusers values('"+firstname+"','"+lastname+"','"+gender+"')");
        if(count>0)
        {
            out.println("Records Entered Successfully");
        }
        else
            out.println("Insertion Failed");
    }
}
catch(Exception e)
{
    out.println(e);
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Connecting to DB with use of JSP is old fashioned and should not be used any more. So if you wish to interact with DB you should use JSP page with form for data entry, then pass it to servlet that will store data in DB and then to progress to futher action. Data validation can be done on JSP or servlet depends on your requirements and your abilities. For some tutorials you should check Sun website or see these tutorials

This question has already been answered. Start a new discussion instead.