home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-03-27 | 1.8 KB | 58 lines |
- /*
- * @(#)TableExample1.java 1.8 98/08/26
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- /**
- * A minimal example, using the JTable to view data from a database.
- *
- * @version 1.20 09/25/97
- * @author Philip Milne
- */
-
- import javax.swing.*;
-
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import java.awt.Dimension;
-
- public class TableExample1 {
-
- public TableExample1(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);
- }
-
- public static void main(String[] args) {
- if (args.length != 5) {
- System.err.println("Needs database parameters eg. ...");
- System.err.println("java TableExample1 \"jdbc:sybase://dbtest:1455/pubs2\" \"connect.sybase.SybaseDriver\" guest trustworthy \"select * from titles\"");
- return;
- }
- new TableExample1(args[0], args[1], args[2], args[3], args[4]);
- }
- }
-