Problem with a program from book
Hello. I have copied this program from one of the books (Ivor Horton's Beginning JAVA 2) and there are three mistakes which I cannot correct them. If you can give me any hint it would be very helpfull to me.
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.SQLException;
public class InteractiveSQL extends JFrame
{
public static void main(String [] args)
{
InteractiveSQL theApp=new InteractiveSQL("sun.jdbc.odbc.JdbcOdbcDriver","jdb c:odbc:contact","admin","rjdemo");
}
public InteractiveSQL(String driver, String url, String user, String password)
{
super("InteractiveSQL");
setBounds(0, 0, 400, 300);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
});
command.setToolTipText("Key SQL command and press Enter");
getContentPane().add(command, BorderLayout.NORTH);
status.setLineWrap(true);
status.setWrapStyleWord(true);
getContentPane().add(status, BorderLayout.SOUTH);
JMenu fileMenu= new JMenu("File");
fileMenu.setMnemonic('F');
fileMenu.add(clearQueryItem);
fileMenu.add(exitItem);
menuBar.add(fileMenu);
setJMenuBar(menuBar);
try
{
Class.forName(driver);
connection= DriverManager.getConnection(url, user, password);
statement= connection.createStatement();
model= new ResultsModel();
JTable table= new JTable(model);
table.setAutoResizeModel(JTable.AUTO_RESIZE_OFF);
resultsPane= new JScrollPane(table);
getContentPane().add(resultsPane, BorderLayout.CENTER);
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
pack();
setVisible(true);
}
JTextField command= new JTextField();
JTextArea status= new JTextArea(3, 1);
JScrollPane resultsPane;
JMenuBar menuBar= new JMenuBar();
JMenuItem clearQueryItem= new JMenuItem("Clear query");
JMenuItem exitItem= new JMenuItem("Exit");
Connection connection;
Statement statement;
ResultsModel model;
}
Thank you in Advance
|