• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

data insertion error into mysql database

 
Numaan Mir
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add data entered from Java GUI into mysql database and inside actionlestener I am using the following code:



'name' is the column in database;
i am having a successful connection to database but the data field entry into database is blank but on every insertion, it prompts 1 row inserted but the data is not seen inside the database.
please help.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35276
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You are creating a new object and immediately getting the value which is blank. Where do you want the data to be coming from?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Numaan Mir,

First of all, a warm welcome to CodeRanch!

Numaan Mir wrote:I want to add data entered from Java GUI into mysql database and inside actionlestener I am using the following code:

Like Jeanne already mentioned: why are you creating a new text field in the action listener. That's not what you would expect. You expect to have a screen with a text field and a button (both are created once in the constructor of your panel or dialog). When you click the button, an action listener is executed and in this action listener you get the name from the text field and insert it into the database. Something like

Hope it helps!
Kind regards,
Roel

PS. Always use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. I've gone ahead and added the code tags for you. See how much easier the code is to read?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic