In this example, i am using an MS Access database and created a table called employee. This table contains fileds empid, name, position and department. Some sample data was added too.
Let’s follow the steps to do it:
Step 1: Create the table in MS Access and make sure you put the database file inside your NetBeans Project Folder.
Step 2: Create database engine to retrieve data from the Access table:
Create a class called DBEngine to retrieve the data from Access (Make
sure you had created a new NetBeans Project first for this tutorial)
Note: i used project.engine package for example only. You are free to create yours.
The following code is done in the DBEngine.java. Basically its a class to retrieve all the data from Employee table using JDBC.

Step 3: Now create the GUI with a JTable component inside it.
Create a new JFrame Form
I named the class TableExample and created under project.gui package.
Add a JTable component onto the Frame.
Step 4: After inserting the JTable component, switch to Source view, we need to insert coding to retrieve data from database.
Add a JTable component onto the Frame.
Step 5: Add the following codes as shown below.
Code you need to add are:
line 03 and 04 (import packages)
line 12 and 13 (instantiate two Vector objects, to hold table data and table header)
line 16 (add throws Exception)
line 19 to 27 (to populate data from database into the Vector object and also initialize the table header Vector object)

Step 6: switch back to design view and right click on the JTable component, then select the Customize Code button.
Choose customize code option to customize the codes.
The customize code page will be shown as follow:
Customize code page
Step 7: change the default code into custom property and change the code as follow:
change the codes to let the table to populate the Vector object we created just now.
Step 8: you need to update the main method to handle exception using try… catch block
Search for the main method in the code view and modify it with adding try…catch block as shown follow: