01: /*
02: * $Author$
03: * $Id$
04: * This is free software, as software should be; you can redistribute
05: * it and/or modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08:
09: * See LICENSE.txt for the full license covering this software/program/code.
10: */
11:
12: package isql.commands;
13:
14: import isql.Command;
15: import util.PerlWrapper;
16: import isql.*;
17: import util.*;
18: import javax.swing.JTextArea;
19: import javax.swing.table.TableModel;
20: import java.awt.Font;
21: import java.util.*;
22:
23: /**
24: * The command object associated with the invoke command, used to
25: * invoke a method in java.sql.DatabaseMetaData.
26: * e.g "invoke supportsBatchOperations()"
27: * "invoke getTables(null,"uid","%", null)"
28: * "invoke methodname(java.sql.ResultSet.TYPE_FORWARD_FETCH_ONLY)"
29: * @author rahul kumar <rahul_kumar@yahoo.com>
30: * @see XXX
31: */
32:
33: public class InvokeCommand implements Command {
34:
35: /** ctor/constructor.
36: */
37: public InvokeCommand() {
38: }
39:
40: public String[] getCommandList() {
41: return commands;
42: }
43:
44: public void execute(SQLForm form, String command, String SQLString) {
45: _form = form;
46:
47: // invoke works on mysql but throws up on Oracle
48: try {
49: Object o = _form.myjdbc.reflectInvoke(SQLString
50: .substring(7));
51: if (o instanceof TableMap) {
52: _form.tp.updateTable((TableModel) o);
53: _form.tp.makeTableAreaVisible();
54: } else {
55: _form.tp.appendOutputArea("\n" + SQLString.substring(7)
56: + "\n " + o.toString());
57: _form.tp.makeOutputAreaVisible();
58: }
59: } catch (Exception exc) {
60: System.err
61: .println("Oracle has problems in invoke, mysql doesnt! Exc: "
62: + exc.toString());
63: }
64:
65: }
66:
67: public String getUsage(String s) {
68: return usage;
69: }
70:
71: String commands[] = { "invoke" };
72: SQLForm _form;
73:
74: final String usage = "invoke <databasemetadata method>";
75:
76: ////// START INSTANCE VARIABLES //////
77:
78: ////// START CONSTANTS AND CLASS LEVEL VARIABLES //////
79: static final String P = "InvokeCommand"; // used in exception strings
80:
81: } // end of class
|