In depth analysis of two methods of binding SQL data source to JTable control in visual swing

In the visual swing of MyEclipse, there is a JTable control. JTable is used to display and edit general 2D cell tables. So, how to bind the data in SQL database to JTable? Here, two methods are provided. Construction method of JTable by consulting the Java API, you can get two important construction methods of JTable: JTable (object [] [] rowdata, object [] columnnames) constructs a JTable to display the values in the two-dimensional array rowdata, and its column name is columnnames. JTable (tablemodel DM) constructs a JTable and initializes it with data model DM, default column model and default selection model.

Next, we use these two construction methods to bind JTable to SQL database.

Necessary preparations 1. There is a database for binding. 2、 Drag in a JTable control in the visual swing. Method 1: bind the two-dimensional array. The construction method used in this method is: JTable (object [] [] rowdata, object [] columnnames) constructs a JTable to display the values in the two-dimensional array rowdata, and its column name is columnnames. Building a two-dimensional array rowdata, we have been able to read the SQL database into the resultset through the learning of the blog post "precompiling" in the previous section. The precompiled comprehensive application analysis in the Preparedstatement class of JDBC is reviewed as follows:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>