An SQLResultSetTablePane presents the results of an SQL (Structured Query Language) query in a table. Each row in the table displays a record from the result set and each column displays a field.
To use an SQLResultSetTablePane, set the connection and query properties. Set properties by using the constructor or the setConnection() and setQuery() methods. Use load() to execute the query and present the results in the table. When the results are no longer needed, call close() to ensure that the result set is closed.
The following example creates an SQLResultSetTablePane object and adds it to a frame:
// Create an SQLResultSetTablePane // object. Assume that "connection" // is an SQLConnection object that is // created and initialized elsewhere. SQLResultSetTablePane tablePane = new SQLResultSetTablePane (connection, "SELECT * FROM QIWS.QCUSTCDT"); // Load the results. tablePane.load (); // Add the table pane to a frame. // Assume that "frame" is a JFrame // created elsewhere. frame.getContentPane ().add (tablePane);Example
Present an SQLResultSetTablePane that displays the contents of a table. This example uses an SQLStatementDocument (denoted in the following image by the text, "Enter a SQL statement here") that allows the user to type in any SQL statement, and an SQLStatementButton (denoted by the text, "Delete all rows") that allows the user to delete all rows from the table.
Figure 1 shows the SQLResultSetTablePane graphical user interface component:
Figure 1: SQLResultSetTablePane GUI component