TableExample2public class TableExample2 extends Object A minimal example, using the JTable to view data from a database. |
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 void | main(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]);
|
|