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.SQLExceptionDialog;
14 import com.quantum.util.connection.ConnectionUtil;
16 import org.eclipse.jface.wizard.WizardPage;
21 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
23 protected SQLResultSetResults.Row row;
24 protected SQLResultSetResults results;
25 private ConnectionUtil connectionUtil = new ConnectionUtil();
27 public BaseSQLPage(String pageName) {
30 public boolean performFinish() {
31 Bookmark bookmark = this.results.getBookmark();
33 bookmark.addQuery(getQueryText());
34 SQLResults sqlResults = MultiSQLServer.getInstance().execute(bookmark,
35 this.connectionUtil.getConnection(bookmark, getShell()), getQueryText());
36 return sqlResults == null ? false : true;
37 } catch (SQLException e) {
38 SQLExceptionDialog.openException(getShell(), bookmark, e);
43 protected abstract String getQueryText();
44 protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
46 if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
47 Column column = getColumn(entity, columnName);
48 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
50 whereClause.append(value);
57 * @throws NotConnectedException
58 * @throws SQLException
60 protected Column getColumn(Entity entity, String columnName) {
62 return entity == null ? null : entity.getColumn(columnName);
63 } catch (NotConnectedException e) {
65 } catch (SQLException e) {
69 public void init(SQLResultSetResults results, SQLResultSetResults.Row row) {
70 this.results = results;