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);
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.