• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inserting text into MySQL from AWT TextFields

 
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic