Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

insert,update and search database data  RSS feed

 
tevin billings
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • 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.
 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Meant to put message above code.made a mistake but it's finally working.thanks appreciate it
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ell us what the problem was and how you solved it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!