• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Inserting text into MySQL from AWT TextFields

 
Greenhorn
Posts: 23
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:

 
Marshal
Posts: 70215
281
  • 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: 23
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: 70215
281
  • 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.
 
Master Rancher
Posts: 4663
49
  • 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: 23
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:

 
My, my, aren't you a big fella. Here, have a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic