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
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.
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.
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.