View Single Post
  #1 (permalink)  
Old April 19th, 2006, 07:06 AM
paulhamo paulhamo is offline
Registered User
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Im trying to insert data into mysql using jsp

Can you advice me on my code, im new to this- im trying to insert data into mysql using a jsp form.. Am i doing this correctly. any help, much appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

        <form action="Registration.jsp" method=post>

        <table cellpadding=4 cellspacing=2 border=0>
        <th bgcolor="#CCCCFF" colspan=2>
        <tr bgcolor="#c8d8f8">
        <td valign=top>

        <b>First Name</b><br>
        <input type="text" name="firstName" value="" size=15 maxlength=20></td>
        <td valign=top>

        <b>Last Name</b><br>
        <input type="text" name="lastName" value="" size=15 maxlength=20></td>
        <tr bgcolor="#c8d8f8">
        <td valign=top>

        <input type="text" name="email" value="" size=25 maxlength=125>
        <td valign=top>

        <b>Date of Birth </b><br>
        <input type="text" name="dateOfBirth" value="" size=15 maxlength=5></td>
        <tr bgcolor="#c8d8f8">
        <td valign=top colspan=2>
        <div align="center">

        <b>Desired User Name</b><br>
              <input type="text" name="userName" size=30 value="" maxlength=10>
        <tr bgcolor="#c8d8f8">
        <td valign=top>

        <input type="password" name="password" size=10 value=""
        <td valign=top>

        <b>Confirm Password</b><br>
        <input type="password" name="password2" size=10 value=""
        <tr bgcolor="#c8d8f8">
        <td valign=top colspan=2>
        <div align="center">

          <input type="radio" name="notify" value="Yes" checked>
        <input type="radio" name="notify" value="No" >
        <tr bgcolor="#c8d8f8">
        <td align=center colspan=2>

        <input type="submit" value="Submit"> <input type="reset"


////////////////////////////////jsp code
        Connection conn = null;
    String username= "lovers";
        String password= "project";
    String url= "jdbc:mysql://";

    String userName1 = request.getParameter("userName");
        String password1 = request.getParameter("password");
    String eaddress = request.getParameter("email");
        String dob = request.getParameter("dateOfBirth");
        String ************ = request.getParameter("notify");

            Class.forName("com.mysql.jdbc.Driver").newInstance ();
            conn = DriverManager.getConnection (url, userName, password);

            java.sql.Date age= java.sql.Date.valueOf(dob);

            PreparedStatment st;
            st = conn.prepareStatement("INSERT INTO REGISTRATION (USERID, USERNAME, PASSWORD, EMAIL, DATEOFBIRTH, ************) VALUES (?,?,?,?,?,?)");



        catch(Exception e)



Reply With Quote