All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.SQLQueryBuilderPane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----javax.swing.JComponent
                           |
                           +----com.ibm.as400.vaccess.SQLQueryBuilderPane

public class SQLQueryBuilderPane
extends JComponent
implements Serializable
The SQLQueryBuilderPane class represents a panel which allows a user to dynamically build a SQL query using graphical interfaces. The corresponding SQL is generated.

Data for the GUI is retrieved from the system when load() is called. If load() is not called, the tables in the GUI will be empty.

If table names are provided, then the user is presented choices based on the fields within those tables. If userSelectTables is true, the user may modify the tables on which the query is built. tableSchemas and userSelectTableSchemas are used to determine the list of tables which the user can choose from, however the user is not prevented from using tables not in these schemas.

It is up to the user to register a JDBC driver when using this class. For example, the following code registers the AS/400 Toolbox for Java JDBC driver.

DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());

Most errors are reported by firing ErrorEvents, rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.

SQLQueryBuilderPane objects generate the following events:

// Register JDBC driver.
DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
// Set up table for result set contents.
final SQLConnection connection = new SQLConnection("MySystem");
final SQLQueryBuilderPane pane = new SQLQueryBuilderPane(connection);
// Set up window to hold table
JFrame frame = new JFrame ("My Window");
WindowListener l = new WindowAdapter()
{
// Close the pane when window is closed.
public void windowClosing(WindowEvent e)
{
pane.close();
connection.close();
}
};
frame.addWindowListener(l);
// Set up the error dialog adapter.
pane.addErrorListener (new ErrorDialogAdapter (frame));
// Add the component and get data from system.
frame.getContentPane().add(pane);
pane.load();
// Display the window
frame.setVisible(true)


Constructor Index

 o SQLQueryBuilderPane()
Constructs a SQLQueryBuilderPane object.
 o SQLQueryBuilderPane(SQLConnection)
Constructs a SQLQueryBuilderPane object.
 o SQLQueryBuilderPane(SQLConnection, String[])
Constructs a SQLQueryBuilderPane object.

Method Index

 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o getConnection()
Returns the SQL connection with which to access data for the GUI.
 o getQuery()
Returns the SQL query that corresponds to the user's selections.
 o getTables()
Returns the names of the tables used in the query.
 o getTableSchemas()
Returns the schemas for which the tables will be listed for inclusion in the query.
 o getUserSelectTables()
Returns true if the user is able to select and change the tables that are included in the query.
 o getUserSelectTableSchemas()
Returns true if the user is able to select and change the schemas for which tables are shown.
 o load()
Gets data from the system.
 o removeErrorListener(ErrorListener)
Removes a listener from being notified when an error occurs.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from being notified when the value of any bound property is changed.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from being notified when the value of any constrained property is changed.
 o setConnection(SQLConnection)
Sets the SQL connection with which to access data for the GUI.
 o setTables(String[])
Sets the table names for the query.
 o setTableSchemas(String[])
Sets the schemas for which the tables will be listed for inclusion in the query.
 o setUserSelectTables(boolean)
Sets whether the user will be able to select and change the tables that are included in the query.
 o setUserSelectTableSchemas(boolean)
Sets whether the user will be able to select and change the schemas for which tables are shown.

Constructors

 o SQLQueryBuilderPane
 public SQLQueryBuilderPane()
Constructs a SQLQueryBuilderPane object.

 o SQLQueryBuilderPane
 public SQLQueryBuilderPane(SQLConnection connection)
Constructs a SQLQueryBuilderPane object.

Parameters:
connection - The SQL connection.
 o SQLQueryBuilderPane
 public SQLQueryBuilderPane(SQLConnection connection,
                            String tables[])
Constructs a SQLQueryBuilderPane object.

Parameters:
connection - The SQL connection.
tables - The names of the tables to be used for the query. Tables should be in the form of ..

Methods

 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs. The listener's errorOccurred() method will be called.

Parameters:
listener - The listener.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The listener's propertyChange() method will be called.

Parameters:
listener - The listener.
Overrides:
addPropertyChangeListener in class JComponent
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The listener's vetoableChange() method will be called.

Parameters:
listener - The listener.
Overrides:
addVetoableChangeListener in class JComponent
 o getConnection
 public SQLConnection getConnection()
Returns the SQL connection with which to access data for the GUI.

Returns:
The SQL connection.
 o getQuery
 public synchronized String getQuery()
Returns the SQL query that corresponds to the user's selections. An empty String is returned if no tables have been selected.

Returns:
The SQL query that corresponds to the user's selections.
 o getTables
 public String[] getTables()
Returns the names of the tables used in the query.

Returns:
The table names.
 o getTableSchemas
 public String[] getTableSchemas()
Returns the schemas for which the tables will be listed for inclusion in the query.

Returns:
The schema names.
 o getUserSelectTables
 public boolean getUserSelectTables()
Returns true if the user is able to select and change the tables that are included in the query. This property controls when the table page is enabled or disabled. The default value is true.

Returns:
true if the user is allowed to change the tables in the query; false otherwise.
 o getUserSelectTableSchemas
 public boolean getUserSelectTableSchemas()
Returns true if the user is able to select and change the schemas for which tables are shown. This property controls whether the list of tables on the table page is changeable. The default value is true.

Returns:
true if the user is allowed to change the schemas whose tables are shown; false otherwise.
 o load
 public synchronized void load()
Gets data from the system. If the connection is null, the AS/400 JDBC driver will be used, and the user will be prompted for sign-on information.

 o removeErrorListener
 public void removeErrorListener(ErrorListener listener)
Removes a listener from being notified when an error occurs.

Parameters:
listener - The listener.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from being notified when the value of any bound property is changed.

Parameters:
listener - The listener.
Overrides:
removePropertyChangeListener in class JComponent
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener from being notified when the value of any constrained property is changed.

Parameters:
listener - The listener.
Overrides:
removeVetoableChangeListener in class JComponent
 o setConnection
 public void setConnection(SQLConnection connection) throws PropertyVetoException
Sets the SQL connection with which to access data for the GUI. This property is bound and constrained. Note that the data in the GUI will not change until a load() is done.

Parameters:
connection - The SQL connection.
Throws: PropertyVetoException
If the change is vetoed.
 o setTables
 public void setTables(String tables[]) throws PropertyVetoException
Sets the table names for the query. This property is bound and constrained. Note that the data in the GUI will not change until a load() is done.

Parameters:
tables - The names of the tables used in the query. Tables should be in the form of .
.
Throws: PropertyVetoException
If the change is vetoed.
 o setTableSchemas
 public void setTableSchemas(String tableSchemas[]) throws PropertyVetoException
Sets the schemas for which the tables will be listed for inclusion in the query. The default is no schemas, so no tables will be listed. This property is bound and constrained.

Parameters:
schemas - The schemas for which tables will be listed.
Throws: PropertyVetoException
If the change is vetoed.
 o setUserSelectTables
 public void setUserSelectTables(boolean flag) throws PropertyVetoException
Sets whether the user will be able to select and change the tables that are included in the query. This property controls when the table page is enabled or disabled. The default value is true. This property is bound and constrained.

Parameters:
flag - true if the user is allowed to change the tables in the query; false otherwise.
Throws: PropertyVetoException
If the change is vetoed.
 o setUserSelectTableSchemas
 public void setUserSelectTableSchemas(boolean flag) throws PropertyVetoException
Sets whether the user will be able to select and change the schemas for which tables are shown. This property controls whether the list of tables on the table page is changeable. The default value is true. This property is bound and constrained.

Parameters:
flag - true if the user is allowed to change the schemas whose tables are shown; false otherwise.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index