01: /*
02: * WbEnableOraOutput.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.sql.wbcommands;
13:
14: import java.sql.SQLException;
15:
16: import workbench.db.WbConnection;
17: import workbench.resource.ResourceMgr;
18: import workbench.sql.SqlCommand;
19: import workbench.sql.StatementRunnerResult;
20: import workbench.sql.formatter.SQLLexer;
21: import workbench.sql.formatter.SQLToken;
22:
23: /**
24: *
25: * @author support@sql-workbench.net
26: */
27: public class WbEnableOraOutput extends SqlCommand {
28: public static final String VERB = "ENABLEOUT";
29:
30: public WbEnableOraOutput() {
31: }
32:
33: public String getVerb() {
34: return VERB;
35: }
36:
37: public StatementRunnerResult execute(String aSql)
38: throws SQLException, Exception {
39: SQLLexer lexer = new SQLLexer(aSql);
40: SQLToken t = lexer.getNextToken(false, false);
41:
42: // First token is the verb
43: if (t != null)
44: t = lexer.getNextToken(false, false);
45:
46: long limit = -1;
47:
48: // second token is the buffer size
49: if (t != null) {
50: String value = t.getContents();
51: try {
52: limit = Long.parseLong(value);
53: } catch (NumberFormatException nfe) {
54: limit = -1;
55: }
56: }
57: currentConnection.getMetadata().enableOutput(limit);
58: StatementRunnerResult result = new StatementRunnerResult();
59: result
60: .addMessage(ResourceMgr
61: .getString("MsgDbmsOutputEnabled"));
62: return result;
63: }
64:
65: }
|