| java.lang.Object | |||
| ↳ | javax.swing.AbstractAction | ||
| ↳ | org.mbari.awt.event.ActionAdapter | ||
| ↳ | vars.query.ui.db.sql.QueryAction | ||
This action takes a SQL query (as a string) and an IQueryable object, executes the query in a seperate thread and returns the results as a QueryResults object. Here's an example of usage:
 // Create our IQueryable object to execute our query
 IQueryable q = new IQueryable() {
     public QueryResults executeQuery(String query) {
         // Get a JDBC connection
         Connection c = ConnectionFactory.getConnection("vars");
         Statement stmt = conn.createStatement();
         ResultSet rs = stmt.executeQuery(query);
         QueryResults queryResults = new QueryResults(rs);
         s.close();
         c.close();
         return queryResults;
     }
 };
 // Initialize our QueryAction
 QueryAction a = new QueryAction("SELECT * from MyTable", q);
 // We'll add some exception handling just to notify us of an error. This is optional
 a.addExceptionHandler(new ExceptionHandler() {
     public void doAction(Exception e) {
         e.printStackTrace();
     }
 });
 // Since it's multithreaded we can't just call getQueryResults because the
 // query may not be finished (Calling getQueryResults would return null). So we
 // attach a PropertyChangeListener to handle post query work
 a.addPropertyChangeListener("queryResults", new PropertyChangeListener() {
     public void propertyChange(PropertyChangeEvent evt) {
         System.out.println("Query is done");
         // Normally you would put save or display code here.
     }
 });
 
| 
  [Expand]
   Inherited Constants  | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
   From interface
javax.swing.Action
 | |||||||||||
| 
  [Expand]
   Inherited Fields  | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
   From class
javax.swing.AbstractAction
 | |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructor for the QueryAction object 
  
   | |||||||||||
Constructs ... 
  
   | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Adds a feature to the PropertyChangeListener attribute of the QueryAction object 
  
   | |||||||||||
Description of the Method
 
  
   | |||||||||||
Description of the Method 
  
   | |||||||||||
| 
  [Expand]
   Inherited Methods  | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
   
From class
  org.mbari.awt.event.ActionAdapter
 | |||||||||||
   
From class
  javax.swing.AbstractAction
 | |||||||||||
   
From class
  java.lang.Object
 | |||||||||||
   
From interface
  java.awt.event.ActionListener
 | |||||||||||
   
From interface
  javax.swing.Action
 | |||||||||||
   
From interface
  org.mbari.awt.event.IAction
 | |||||||||||
Constructor for the QueryAction object
| query | Description of the Parameter | 
|---|---|
| queryable | Description of the Parameter | 
Constructs ...
Adds a feature to the PropertyChangeListener attribute of the QueryAction object
| listener | The feature to be added to the PropertyChangeListener attribute | 
|---|
Description of the Method
Description of the Method
| listener | Description of the Parameter | 
|---|