FileDocCategorySizeDatePackage
TableExample2.javaAPI DocSun JDK 1.4.2 Example3242Thu May 12 00:35:28 BST 2005None

TableExample2

public class TableExample2 extends Object
A minimal example, using the JTable to view data from a database.
version
1.20 09/25/97
author
Philip Milne

Fields Summary
Constructors Summary
public TableExample2(String URL, String driver, String user, String passwd, String query)

        JFrame frame = new JFrame("Table");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}});
        JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
        dt.executeQuery(query);

        // Create the table
        JTable tableView = new JTable(dt);

        JScrollPane scrollpane = new JScrollPane(tableView);
        scrollpane.setPreferredSize(new Dimension(700, 300));

        frame.getContentPane().add(scrollpane);
        frame.pack();
        frame.setVisible(true);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        if (args.length != 5) {
            System.err.println("Needs database parameters eg. ...");
            System.err.println("java TableExample2 \"jdbc:sybase://dbtest:1455/pubs2\" \"connect.sybase.SybaseDriver\" guest trustworthy \"select * from titles\"");
            return;
        }
        new TableExample2(args[0], args[1], args[2], args[3], args[4]);