1 package com.quantum.wizards;
3 import java.sql.SQLException;
5 import com.quantum.adapters.DatabaseAdapter;
6 import com.quantum.model.Bookmark;
7 import com.quantum.model.Column;
8 import com.quantum.model.Entity;
9 import com.quantum.model.NotConnectedException;
10 import com.quantum.sql.MultiSQLServer;
11 import com.quantum.sql.SQLResultSetResults;
12 import com.quantum.sql.SQLResults;
13 import com.quantum.ui.dialog.ExceptionDisplayDialog;
14 import com.quantum.util.connection.ConnectionUtil;
16 import org.eclipse.jface.wizard.WizardPage;
22 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
24 protected SQLResultSetResults.Row row;
25 protected SQLResultSetResults results;
26 private ConnectionUtil connectionUtil = new ConnectionUtil();
28 public BaseSQLPage(String pageName) {
31 public boolean performFinish() {
33 Bookmark bookmark = this.results.getBookmark();
34 bookmark.addQuery(getQueryText());
35 SQLResults sqlResults = MultiSQLServer.getInstance().execute(bookmark,
36 this.connectionUtil.getConnection(bookmark, getShell()), getQueryText());
37 return sqlResults == null ? false : true;
38 } catch (SQLException e) {
39 ExceptionDisplayDialog.openError(getShell(), null, null, e);
44 protected abstract String getQueryText();
45 protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
47 if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
48 Column column = getColumn(entity, columnName);
49 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
51 whereClause.append(value);
58 * @throws NotConnectedException
59 * @throws SQLException
61 protected Column getColumn(Entity entity, String columnName) {
63 return entity == null ? null : entity.getColumn(columnName);
64 } catch (NotConnectedException e) {
66 } catch (SQLException e) {
70 public void init(SQLResultSetResults results, SQLResultSetResults.Row row) {
71 this.results = results;