p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Language (http://p2p.wrox.com/forumdisplay.php?f=100)
-   -   Im trying to insert data into mysql using jsp (http://p2p.wrox.com/showthread.php?t=41466)

paulhamo April 19th, 2006 07:06 AM

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<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://csserver.ucd.ie/lovers";

    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)



sharad_iips2003 September 12th, 2006 02:35 AM

I am also getting a similar problem while inserting into a student table in database iips. If you now have the solution , please help....I would be very thankful to you...

All times are GMT -4. The time now is 02:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.