Issue
I'm new to PostgreSQL and Java Swing.
In PostgreSQL company
database, I have a users
table and it has 4 fields: user_id, username, phone, and address.
CREATE TABLE users
(
user_id serial primary key,
username VARCHAR(40) not null,
phone VARCHAR(14) not null,
address VARCHAR(50)
);
I'm trying to load all fields from users
table to JTable
in Java Swing using Bound (Figure 1).
Then I bind the elements from the table (Figure 2).
As you can see in Figure 2, it shows only 3 fields except user_id
. I need to load this user_id
field as well because I need to perform CRUD data.
How can I achieve that?
Solution
I finally got the solution.
When I import the data from the database to the form, the Model (for example; Users.java) file is generated.
The problem was I firstly generated that file and later I added the user_id
column to the database, so guess what, the Model file is somehow not updated and so the user_id
is not there.
Therefore, I had manually added getter and setter for the user_id
field, and now ok.
Answered By - Htet Phyo Naing
Answer Checked By - Timothy Miller (JavaFixing Admin)