Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to insert data in MYSQL with jsp

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation How to insert data in MYSQL with jsp

    how can i insert data into mysql table if my table look like this:

    masina(Serie, ProducatorM, ModelM, ProprietarM, An_fabricatie, Combustibil, Culoare, Culoare, Dotari, Poza)

    my form look like this: Producator, Model, An_fabricatie, Combustibil, Culoare, Dotari

    Serie - int, autoincrement, pk, can be null
    ProducatorM - string, fk = Producator
    ModelM - string, fk = Model
    ProprietarM - string, fk = ??? (how to make this to automate take my Nick when i'm login)
    An_fabricatie - string = An_fabricatie
    Combustibil - string = Combustibil
    Culoare - string = Culoare
    Dotari - string = Dotari
    Poza - can be null


    my problem appear when i try to insert data into masina, because i'm logged in and i dont know how to set ProprietarM to get automate my nick(login nick) and put it in table..can anybody help me?

    here's code from project, eclipse ee, jsp


    form to complete - this is in admin.jsp
    <td>
    <h2>Adauga masina</h2>
        </td>
          </tr>
    	 <tr>
    	    <td>
    		<form id="filter" method="post">
    		    <table width="438" border="0" cellspacing="0" cellpadding="0">
    			<tr>
    				</tr>
    				    <tr>  
                                            <td>Producator</td>
    			<td style="height: 40px"><input type="text" name="DenumireP" />             </td>
    					</tr>
    						<tr>
    						<td>Model</td>
    				<td style="height: 40px"><input type="text" name="Denumire" /></td>
    				</tr>																	      <tr>
    				<td>An fabricatie</td>
    				<td style="height: 40px">
                <input type="text" name="An_fabricatie" /></td>
    			</tr>
    				<tr>
    					<td>Combustibil</td>
    				<td style="height: 40px"><input type="text" name="Combustibil" /></td>
    					</tr>
    						<tr>
    					<td>Culoare</td>
    				td style="height: 40px"><input type="text" name="Culoare" /></td>
    					</tr>
    					<tr>
    					<td>Dotari</td>
    			<td style="height: 40px"><textarea name="Dotari"
    				cols="40"	rows="7"></textarea></td> 
    				</tr>
    				<tr>
    					<td>Adauga</td>
    			<td style="height: 40px"><input type="submit"
    			value="Adauga" name="save" /></td>
    			</tr>
    				</table>
     
    				</form>
    			</td>
    				</tr>

    save to database function - this is in Masini.java
    public boolean save (String p, String m, String pp, String a, String c, String cul, String d) 
    {  String q = "INSERT INTO masina(ProducatorM, ModelM, ProprietarM, An_fabricatie, Combustibil, Culoare, Dotari) VALUES ('" + p + "','" + m + "','" + pp + "','" + a + "','" + c + "','" + c + "','" + d + "')";
    	return ppauto.query(q);


  2. #2
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: How to insert data in MYSQL with jsp


  3. The Following User Says Thank You to dineshj83 For This Useful Post:

    blasic (November 25th, 2013)

  4. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to insert data in MYSQL with jsp

    Quote Originally Posted by dineshj83 View Post
    ty, i did that and now data insert into table works, but doen't take my username... and where should be my username, put null, and doen't help me , anyway ty, if somebody else cand help me please do it

  5. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to insert data in MYSQL with jsp

    administrator/moderator close topic, thanks

Similar Threads

  1. problem - insert negative value to mysql database.
    By vasanthjayaraman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 12th, 2013, 09:45 AM
  2. Replies: 1
    Last Post: June 29th, 2012, 01:29 PM
  3. Replies: 1
    Last Post: April 9th, 2012, 05:13 PM
  4. Replies: 2
    Last Post: June 15th, 2011, 03:49 PM
  5. Replies: 1
    Last Post: June 11th, 2011, 05:39 AM