开发者

Populate a jTable Using MySQL

I have a project with a jTable called AchTa开发者_StackOverflow社区ble, 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜