Nathan Campos
Nathan Campos

Reputation: 29497

Populate a jTable Using MySQL

I have a project with a jTable called AchTable, that is like this:

+-------+------+
| File  | Type |
+-------+------+
|       |      |
|       |      |
|       |      |
+--------------+

And I have a mySQL table that is like the same, then I want to know how could I populate the jTable.

Upvotes: 0

Views: 2133

Answers (1)

camickr
camickr

Reputation: 324108

So what is the problem, creating a table or creating an SQL query?

Read the section from the Swing tutorial on How to Use Tables.

Read the tutorial on JDBC Database Access.

Put the two together and you've got your problem solved. That is first create your query and create a ResultSet. Then you use the meta data to get the column names. Then you loop through the ResultSet and add rows of data to your table. You can use a DefaultTableModel for this.

Upvotes: 1

Related Questions