• 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

insert,update and search database data

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys
I am busy with an assignment question that requires us to link a ms access database to netbeans. we are then supposed to create a gui where we will need to create a button that when we enter data into text fields enable us to click on the button and the data will be stored directly into the database, we also have create an update and search button.
Here is what i have done so far.when i run the program it shows null null null null null on the console
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is too much code to check.. Can you check the places where you are setting the values of the variables? It may possible that
values are not setting properly.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another thing to do is debug the SQL statements.
In this case just print them out, that way you can see whether they are being executed at all and if so with what data.

I will note, though you are using a PreparedStatement in the code, you are not using it properly. You are still concatenating your SQL together, when you should have something like:


The way you are doing it there is no point having a PreparedStatement at all as you gain none of the security and syntax protection.
 
tevin billings
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you've misplaced your opening code tag.

And why have you posted all that code again without comment?
Has something changed?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can correct the code tag←link problem, but DT is correct. You cannot expect anybody to go through that amount of code looking for errors. Least of all when it is automatically created code from NetBeans, which is notorious for its illegibility. Also for the length and density of the group layout lines, which are even harder to read.
Start by writing code which updates your database without a GUI at all. Give it a public interface with methods like setName setPhone etc, or a constructor. Also a class with methods like writeToDatabase. Set all those values from a non‑GUI app:-Run that. Then check that the database has actually got the update. Then upgrade it to this sort of thing:-Again check you have updated the database.
Are you sure you have got the syntax for the update right? Shouldn't there be a WHERE clause as well? Note you need a different Employee class from what you have in NetBeans. Don't call a GUI class Employee. Give it a name which makes it obvious it is a display class.

Once you have got that sort of code working, it should be easy to add a GUI to display your results and enter data.
 
tevin billings
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Meant to put message above code.made a mistake but it's finally working.thanks appreciate it
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ell us what the problem was and how you solved it.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic