InvokeCommand.java :  » Database-Client » SQLMinus » isql » commands » Java Open Source

Java Open Source » Database Client » SQLMinus 
SQLMinus » isql » commands » InvokeCommand.java
/*
 * $Author$
 * $Id$
 * This is free software, as software should be; you can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * See LICENSE.txt for the full license covering this software/program/code.
 */
 
package isql.commands;
import isql.Command;
import util.PerlWrapper;
import isql.*;
import util.*;
import javax.swing.JTextArea;
import javax.swing.table.TableModel;
import java.awt.Font;
import java.util.*;

/**
 * The command object associated with the invoke command, used to 
 * invoke a method in java.sql.DatabaseMetaData.
 * e.g  "invoke supportsBatchOperations()"
 *      "invoke getTables(null,"uid","%", null)"
 *      "invoke methodname(java.sql.ResultSet.TYPE_FORWARD_FETCH_ONLY)"
 * @author rahul kumar <rahul_kumar@yahoo.com>
 * @see XXX
 */

public class InvokeCommand implements Command {

    /** ctor/constructor.
     */
    public InvokeCommand (){
    }
    public String[] getCommandList(){
        return commands;
    }
    public void execute (SQLForm form, String command, String SQLString){
        _form = form;

        // invoke works on mysql but throws up on Oracle
            try {
                Object o = _form.myjdbc.reflectInvoke(SQLString.substring(7));
                if (o instanceof TableMap){
                    _form.tp.updateTable((TableModel)o);
                    _form.tp.makeTableAreaVisible();
                } else {
                    _form.tp.appendOutputArea ("\n"+SQLString.substring(7)+"\n "+o.toString());
                    _form.tp.makeOutputAreaVisible();
                }
            } catch (Exception exc){ System.err.println("Oracle has problems in invoke, mysql doesnt! Exc: "+exc.toString()); 
            } 

    }



    public String getUsage(String s){
        return usage;
    }


    String commands[] = {"invoke"};
    SQLForm _form;

    final String usage = "invoke <databasemetadata method>";


    ////// START INSTANCE VARIABLES //////

    ////// START CONSTANTS AND CLASS LEVEL VARIABLES  //////
    static final String P = "InvokeCommand"; // used in exception strings

} // end of class



java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.