01: package net.sourceforge.squirrel_sql.client.session;
02:
03: /*
04: * Copyright (C) 2003-2004 Jason Height
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: import java.sql.ResultSet;
21: import java.sql.SQLException;
22: import java.sql.SQLWarning;
23:
24: import net.sourceforge.squirrel_sql.fw.datasetviewer.IDataSetUpdateableTableModel;
25: import net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter;
26:
27: /**
28: * This default implementation of the sql executer handler simply notifies the
29: * message handler when events occur.
30: *
31: * @author <A HREF="mailto:jmheight@users.sourceforge.net">Jason Height</A>
32: */
33: public class DefaultSQLExecuterHandler implements ISQLExecuterHandler {
34: private ISession _session;
35:
36: public DefaultSQLExecuterHandler(ISession session) {
37: _session = session;
38: }
39:
40: public void sqlToBeExecuted(String sql) {
41: }
42:
43: public void sqlExecutionCancelled() {
44: }
45:
46: public void sqlDataUpdated(int updateCount) {
47: }
48:
49: public void sqlResultSetAvailable(ResultSet rst,
50: SQLExecutionInfo info, IDataSetUpdateableTableModel model) {
51: }
52:
53: public void sqlExecutionComplete(SQLExecutionInfo info,
54: int processedStatementCount, int statementCount) {
55: }
56:
57: public void sqlExecutionException(Throwable th,
58: String postErrorString) {
59: String msg = "Error: ";
60:
61: if (th instanceof SQLException) {
62: SQLException sqlEx = (SQLException) th;
63: sqlEx.getSQLState();
64: sqlEx.getErrorCode();
65:
66: msg += sqlEx + ", SQL State: " + sqlEx.getSQLState()
67: + ", Error Code: " + sqlEx.getErrorCode();
68: } else {
69: msg += th;
70: }
71:
72: if (null != postErrorString) {
73: msg += "\n" + postErrorString;
74: }
75:
76: _session.showErrorMessage(msg);
77: }
78:
79: public void sqlExecutionWarning(SQLWarning warn) {
80: _session.showMessage(warn);
81: }
82:
83: public void sqlStatementCount(int statementCount) {
84: }
85:
86: public void sqlCloseExecutionHandler() {
87: }
88: }
|