This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inserting text into MySQL from AWT TextFields  RSS feed

 
Milos Radovic
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!
For my assignment I need to make application that will take the text from the AWT TextField and insert it into MySQL database.
I wrote some code which doesn’t show any errors and it is inserting the text into database but not the one from the TextFields.
Can anyone help me solve this problem?
Thanks in advance.
Here is the code:

class ConnectionFactory:



class UsersDao:



class Main:

 
Campbell Ritchie
Marshal
Posts: 55708
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use AWT display classes; they have been regarded as obsolete for about 15 years. Use Swing or JavaFX instead.
Have a look at the Java™ Tutorials. I think you will find an example of a GUI linking to a database in there, and I think that will probably tell you most of what you need to know.
 
Milos Radovic
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Don't use AWT display classes; they have been regarded as obsolete for about 15 years. Use Swing or JavaFX instead.

Thanks for your reply. I am aware of that, however it is asked of me to use AWT for my assignment. I tried and tried to make this code work but I just couldn't to it.
I would rally appreciate if anybody could give me some hints and ideas about how can I correct my code.
  
 
Campbell Ritchie
Marshal
Posts: 55708
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't the tutorial link help you? Please tell us what happens; we can only help if we have the full details.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you run your code currently?
What should happen?

At the moment you have hardcoded values for your INSERT statement.
 
Milos Radovic
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Didn't the tutorial link help you? Please tell us what happens; we can only help if we have the full details.


I solved the problem.    I just deleted the class UsersDao and put the code from the Insert method into the button ActionListener in Main class.
Here is the code:

class ConnectionFactory:



class Main:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!