Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Compilation Error

  Asked By: Adelisa    Date: Jun 06    Category: Java    Views: 515
  

Can anyone help me compile this? It would be a great help. It gives
me error in ResultsModel class.

import java.sql.*; // For JDBC classes
import java.io.*;
import javax.naming.*;
import java.rmi.RemoteException;
import java.util.*;
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.text.*;
import javax.swing.table.*;
import javax.swing.tree.*;


public class InteractiveSQL extends JFrame
{
public static void main(String[] args)
{ // Create the application object
InteractiveSQL theApp = new InteractiveSQL
("sun.jdbc.odbc.JdbcOdbcDriver",

"jdbc:odbc:addr_bo
ok",
"guest",
"guest");
}

public InteractiveSQL(String driver, String url,
String user, String password)
{
super("Interactive
SQL"); // Call base constructor
setBounds
(0,0,400,300); // Set window
bounds
setDefaultCloseOperation
(DISPOSE_ON_CLOSE); // Close window operation
addWindowListener(new WindowHandler
()); // Listener for window close

// Add the input for SQL statements at the top
command.setToolTipText("Key SQL command and press
enter");
getContentPane().add(command, BorderLayout.NORTH);

// Add the status reporting area at the bottom
status.setLineWrap(true);
status.setWrapStyleWord(true);
getContentPane().add(status, BorderLayout.SOUTH);

//Create the menubar from the menu items
JMenu fileMenu = new JMenu
("File"); // Create file menu
fileMenu.setMnemonic
('F'); // Create shortcut
fileMenu.add
(clearQueryItem); // Add clear query
item
fileMenu.add
(exitItem); // Add exit item
menuBar.add
(fileMenu); // Add menu to the
menu bar
setJMenuBar(menuBar);

// Establish a database connection and setup the
table
try
{
Class.forName
(driver); // Load the driver
connection = DriverManager.getConnection
(url, user, password);
statement = connection.createStatement();

model = new ResultsModel
(); // Create a table model
JTable table = new JTable
(model); // Create a table from the model
table.setAutoResizeMode
(JTable.AUTO_RESIZE_OFF); // Use scrollbars
resultsPane = new JScrollPane
(table); // Create scrollpane for table
getContentPane().add(resultsPane,
BorderLayout.CENTER);
}
catch(ClassNotFoundException cnfe)
{
System.err.println
(cnfe); // Driver not found
}
catch (SQLException sqle)
{
System.err.println
(sqle); // Error connection to database
}
pack();
setVisible(true);
}

class WindowHandler extends WindowAdapter
{
// Handler for window closing event
public void WindowClosing(WindowEvent e)
{
dispose
(); // Release the
window resources
System.exit
(0); // End the application
}
}

JTextField command = new JTextField
(); // Input area for SQL
JTextArea status = new JTextArea
(3,1); // Output area for status and errors
JScrollPane resultsPane;

JMenuBar menuBar = new JMenuBar
(); // The menubar
JMenuItem clearQueryItem = new JMenuItem("Clear
Query"); // Clear SQL item
JMenuItem exitItem = new JMenuItem
("Exit"); // Exit item

Connection
connection; // Connection to
the database
Statement
statement; // Statement
object for queries
ResultsModel
model; // Table model for
resultset
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Compilation Error Or get search suggestion and latest updates.




Tagged: