|
From: SVN by r. <sv...@ca...> - 2009-01-16 20:44:19
|
Author: roy
Date: 2009-01-16 21:44:06 +0100 (Fri, 16 Jan 2009)
New Revision: 351
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
improved exception handling
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-16 20:10:20 UTC (rev 350)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-16 20:44:06 UTC (rev 351)
@@ -455,16 +455,23 @@
commandThread = new CommandThread(cmd.cmd) {
@Override
void execute() {
- CommandResult result = getCommand().execute(cmd.sql);
- Iterator<CharSequence> iResult = result.getResult();
- while (iResult.hasNext()) {
- output(iResult.next());
+ try {
+ CommandResult result = getCommand().execute(cmd.sql);
+ if (result.getResult() == null) {
+ output("NULL FOR: "+ result);
+ }
+ Iterator<CharSequence> iResult = result.getResult();
+ while (iResult.hasNext()) {
+ output(iResult.next());
+ repaint();
+ }
+ if (!result.executedSuccessfully()) {
+ output("Execution Failed...\n");
+ }
repaint();
+ } catch(Exception e) {
+ error(e);
}
- if (!result.executedSuccessfully()) {
- output("Execution Failed...\n");
- }
- repaint();
}
};
commandThread.setDaemon(true);
@@ -1035,15 +1042,19 @@
}
output(sqlCommand.getLines());
//repaint();
- CommandResult commandResult = command.execute(sqlCommand);
- Iterator<CharSequence> result = commandResult.getResult();
- while (result.hasNext()) {
- output(result.next());
- repaint();
+ try {
+ CommandResult commandResult = command.execute(sqlCommand);
+ Iterator<CharSequence> result = commandResult.getResult();
+ while (result.hasNext()) {
+ output(result.next());
+ repaint();
+ }
+ if (!commandResult.executedSuccessfully()) {
+ output("Execution Failed...\n");
+ }
+ } catch(Exception e) {
+ error(e);
}
- if (!commandResult.executedSuccessfully()) {
- output("Execution Failed...\n");
- }
repaint();
return true;
}
@@ -2083,14 +2094,14 @@
continue;
}
cmd.append(line);
- //if (line.endsWith(";")) {
- String commandString = cmd.toString();
- currentCommand = sqlShell.createCommand(commandString);
- if (currentCommand == null) {
- continue;
- }
- // Exec cmd
- sqlShell.output(commandString);
+ String commandString = cmd.toString();
+ currentCommand = sqlShell.createCommand(commandString);
+ if (currentCommand == null) {
+ continue;
+ }
+ // Exec cmd
+ sqlShell.output(commandString);
+ try {
CommandResult result = currentCommand.execute(new InputCommand(commandString));
Iterator<CharSequence> output = result.getResult();
while (output.hasNext()) {
@@ -2108,7 +2119,9 @@
sqlShell.repaint();
}
}.start();
- //}
+ } catch(Exception e) {
+ sqlShell.error(e);
+ }
}
if (cancelled) {
return new SimpleCommandResult(true, "Execution of file '" + toFileName(command.substring(1)) +"' aborted....");
@@ -2330,7 +2343,7 @@
try {
return DBConnector.getInstance().getQueryExecutor().executeQuery(command);
} catch (SQLException ex) {
- return null;
+ throw new IllegalArgumentException(ex);
}
}
};
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-01-16 20:10:20 UTC (rev 350)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-01-16 20:44:06 UTC (rev 351)
@@ -237,7 +237,8 @@
}
return displayValue.toString();
} catch(SQLException e) {
- return null;
+ //return "";
+ throw new IllegalArgumentException("Failed to execute query", e);
}
}
|