Java Reference
In-Depth Information
public void actionPerformed(ActionEvent event){
String action = event.getActionCommand();
if(commandListener!=null){
ActionEvent evt = new ActionEvent(this,0,SQLCommand);
commandListener.actionPerformed(evt);
}
}
}
// Listener for Edit events on the JTable
class TableChangeListener implements TableModelListener{
public TableChangeListener (){
}
public void tableChanged(TableModelEvent event){
SQLCommand = SQLCommandRoot+parseTable();
SQLPane.setText(SQLCommand);
}
}
}
Model
The model portion of the MVC model is nothing more than the JDBC class we build earlier in the
chapter. This version has been edited slightly to remove the embedded SQL command strings and the
main() method we use to test it.
We have also changed the exception handling to fire an ActionEvent to an ExceptionListener
registered by the controller, which pops up a JOptionPane to display exceptions from the SQLToolkit
rather than printing them to the console. (See Listing 5-9 .)
Listing 5-9: DatabaseUtilities — the JDBC code
package jdbc_bible.part2;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
import sun.jdbc.odbc.JdbcOdbcDriver;
Search WWH ::




Custom Search