⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databasemanagerswing.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* Copyrights and Licenses * * This product includes Hypersonic SQL. * Originally developed by Thomas Mueller and the Hypersonic SQL Group.  * * Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights reserved.  * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met:  *     -  Redistributions of source code must retain the above copyright notice, this list of conditions *         and the following disclaimer.  *     -  Redistributions in binary form must reproduce the above copyright notice, this list of *         conditions and the following disclaimer in the documentation and/or other materials *         provided with the distribution.  *     -  All advertising materials mentioning features or use of this software must display the *        following acknowledgment: "This product includes Hypersonic SQL."  *     -  Products derived from this software may not be called "Hypersonic SQL" nor may *        "Hypersonic SQL" appear in their names without prior written permission of the *         Hypersonic SQL Group.  *     -  Redistributions of any form whatsoever must retain the following acknowledgment: "This *          product includes Hypersonic SQL."  * This software is provided "as is" and any expressed or implied warranties, including, but * not limited to, the implied warranties of merchantability and fitness for a particular purpose are * disclaimed. In no event shall the Hypersonic SQL Group or its contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential damages (including, but * not limited to, procurement of substitute goods or services; loss of use, data, or profits; * or business interruption). However caused any on any theory of liability, whether in contract, * strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this * software, even if advised of the possibility of such damage.  * This software consists of voluntary contributions made by many individuals on behalf of the * Hypersonic SQL Group. * * * For work added by the HSQL Development Group: * * Copyright (c) 2001-2002, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer, including earlier * license statements (above) and comply with all above license conditions. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution, including earlier * license statements (above) and comply with all above license conditions. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package net.jumperz.ext.org.hsqldb.util;import java.awt.*;import java.awt.event.*;import java.awt.image.*;import java.sql.*;import java.io.File;import java.util.*;import javax.swing.*;import javax.swing.tree.*;// dmarshall@users - 20020101 - original swing port// sqlbob@users 20020401 - patch 537501 by ulrivo - commandline arguments// sqlbob@users 20020407 - patch 1.7.0 - reengineering and enhancements// nickferguson@users 20021005 - patch 1.7.1 - enhancements/** * Swing Tool for manageing a JDBC database.<p> * <pre> *             Usage: java DatabaseManagerSwing [-options] *             where options include: *              -driver <classname>  jdbc driver class *              -url <name>          jdbc url *              -user <name>         username used for connection *              -password <password> password for this user *              -dir <path>          default directory *              -script <file>       reads from script file *</pre> * @version 1.7.0 */public class DatabaseManagerSwing extends JAppletimplements ActionListener, WindowListener, KeyListener {    final static String    NL         = System.getProperty("line.separator");    static int             iMaxRecent = 24;    Connection             cConn;    DatabaseMetaData       dMeta;    Statement              sStatement;    JMenu                  mRecent;    String                 sRecent[];    int                    iRecent;    JTextArea              txtCommand;    JScrollPane            txtCommandScroll;    JButton                butExecute;    JTree                  tTree;    JScrollPane            tScrollPane;    DefaultTreeModel       treeModel;    DefaultMutableTreeNode rootNode;    JPanel                 pResult;    long                   lTime;    int                    iResult;        // 0: grid; 1: text    GridSwing              gResult;    JTable                 gResultTable;    JScrollPane            gScrollPane;    JTextArea              txtResult;    JScrollPane            txtResultScroll;    JSplitPane             nsSplitPane;    // Contains query over results    JSplitPane             ewSplitPane;    // Contains tree beside nsSplitPane    boolean                bHelp;    JFrame                 fMain;    String                 ifHuge = "";    JToolBar               jtoolbar;    // (ulrivo): variables set by arguments from the commandline    static String defDriver   = "net.jumperz.ext.org.hsqldb.jdbcDriver";    static String defURL      = "jdbc:hsqldb:.";    static String defUser     = "sa";    static String defPassword = "";    static String defScript;    static String defDirectory;    public void init() {        DatabaseManagerSwing m = new DatabaseManagerSwing();        m.main();        try {            m.connect(ConnectionDialogSwing.createConnection(defDriver,                    defURL, defUser, defPassword));            m.insertTestData();            m.refreshTree();        } catch (Exception e) {            e.printStackTrace();        }    }    public static void main(String arg[]) {        System.getProperties().put("sun.java2d.noddraw", "true");        // (ulrivo): read all arguments from the command line        String  lowerArg;        boolean autoConnect = false;        for (int i = 0; i < arg.length; i++) {            lowerArg = arg[i].toLowerCase();            i++;            if (i == arg.length) {                showUsage();                return;            }            if (lowerArg.equals("-driver")) {                defDriver   = arg[i];                autoConnect = true;            } else if (lowerArg.equals("-url")) {                defURL      = arg[i];                autoConnect = true;            } else if (lowerArg.equals("-user")) {                defUser     = arg[i];                autoConnect = true;            } else if (lowerArg.equals("-password")) {                defPassword = arg[i];                autoConnect = true;            } else if (lowerArg.equals("-dir")) {                defDirectory = arg[i];            } else if (lowerArg.equals("-script")) {                defScript = arg[i];            } else {                showUsage();                return;            }        }        DatabaseManagerSwing m = new DatabaseManagerSwing();        m.main();        Connection c = null;        try {            if (autoConnect) {                c = ConnectionDialogSwing.createConnection(defDriver, defURL,                        defUser, defPassword);            } else {                c = ConnectionDialogSwing.createConnection(m.fMain,                        "Connect");            }        } catch (Exception e) {            e.printStackTrace();        }        if (c == null) {            return;        }        m.connect(c);    }    private void connect(Connection c) {        if (c == null) {            return;        }        if (cConn != null) {            try {                cConn.close();            } catch (SQLException e) {}        }        cConn = c;        try {            dMeta      = cConn.getMetaData();            sStatement = cConn.createStatement();            refreshTree();        } catch (SQLException e) {            e.printStackTrace();        }    }    private static void showUsage() {        System.out.println(            "Usage: java DatabaseManagerSwing [-options]\n"            + "where options include:\n"            + "    -driver <classname>  jdbc driver class\n"            + "    -url <name>          jdbc url\n"            + "    -user <name>         username used for connection\n"            + "    -password <password> password for this user\n"            + "    -dir <path>          default directory\n"            + "    -script <file>       reads from script file\n");    }    private void insertTestData() {        try {            DatabaseManagerCommon.createTestTables(sStatement);            refreshTree();            txtCommand.setText(                DatabaseManagerCommon.createTestData(sStatement));            refreshTree();            for (int i = 0; i < DatabaseManagerCommon.testDataSql.length;                    i++) {                addToRecent(DatabaseManagerCommon.testDataSql[i]);            }            execute();        } catch (SQLException e) {            e.printStackTrace();        }    }    void main() {        CommonSwing.setDefaultColor();        fMain = new JFrame("HSQL Database Manager");        // (ulrivo): An actual icon.        fMain.getContentPane().add(createToolBar(), "North");        fMain.setIconImage(CommonSwing.getIcon());        fMain.addWindowListener(this);        JMenuBar bar = new JMenuBar();        // used shortcuts: CERGTSIUDOLM        String fitems[] = {            "-Connect...", "--", "-Open Script...", "-Save Script...",            "-Save Result...", "--", "-Exit"        };        addMenu(bar, "File", fitems);        String vitems[] = {            "RRefresh Tree", "--", "GResults in Grid", "TResults in Text"        };        addMenu(bar, "View", vitems);        String sitems[] = {            "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "---",            "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX",            "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--",            "-Test Script"        };        addMenu(bar, "Command", sitems);        mRecent = new JMenu("Recent");        bar.add(mRecent);        String soptions[] = {            "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--",            "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on",            "-Logging off", "--", "-Insert test data"        };        addMenu(bar, "Options", soptions);        String stools[] = {            "-Dump", "-Restore", "-Transfer"        };        addMenu(bar, "Tools", stools);        fMain.setJMenuBar(bar);        initGUI();        sRecent = new String[iMaxRecent];        Dimension d    = Toolkit.getDefaultToolkit().getScreenSize();        Dimension size = fMain.getSize();        // (ulrivo): full size on screen with less than 640 width        if (d.width >= 640) {            fMain.setLocation((d.width - size.width) / 2,                              (d.height - size.height) / 2);        } else {            fMain.setLocation(0, 0);            fMain.setSize(d);        }        fMain.show();        // (ulrivo): load query from command line        if (defScript != null) {            if (defDirectory != null) {                defScript = defDirectory + File.separator + defScript;            }            // if insert stmet is thousands of records...skip showing it            // as text.  Too huge.            StringBuffer buf = new StringBuffer();            ifHuge = DatabaseManagerCommon.readFile(defScript);            if (4096 <= ifHuge.length()) {                buf.append(                    "This huge file cannot be edited. Please execute\n");                txtCommand.setText(buf.toString());            } else {                txtCommand.setText(ifHuge);            }        }        txtCommand.requestFocus();    }    private void addMenu(JMenuBar b, String name, String items[]) {        JMenu menu = new JMenu(name);        addMenuItems(menu, items);        b.add(menu);    }    private void addMenuItems(JMenu f, String m[]) {        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();        for (int i = 0; i < m.length; i++) {            if (m[i].equals("--")) {                f.addSeparator();            } else if (m[i].equals("---")) {                // (ulrivo): full size on screen with less than 640 width                if (d.width >= 640) {                    f.addSeparator();                } else {                    return;                }            } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -