X-Git-Url: http://secure.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java index 459a949..755f9be 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java @@ -1,10 +1,13 @@ package com.quantum.wizards; +import java.sql.SQLException; + import com.quantum.adapters.DatabaseAdapter; import com.quantum.model.Bookmark; import com.quantum.model.Column; import com.quantum.model.ConnectionException; import com.quantum.model.Entity; +import com.quantum.model.NotConnectedException; import com.quantum.sql.TableRow; import com.quantum.view.ViewHelper; import com.quantum.view.tableview.TableAdapter; @@ -34,15 +37,31 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage { } protected abstract String getQueryText(); protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) { - - if (adapter != null && entity != null && entity.getColumn(columnName) != null) { - Column column = entity.getColumn(columnName); + + if (adapter != null && entity != null && getColumn(entity, columnName) != null) { + Column column = getColumn(entity, columnName); whereClause.append(adapter.quote(value, column.getType(), column.getTypeName())); } else { whereClause.append(value); } } - public void init(TableRow row, TableAdapter adapter) { + /** + * @param entity + * @param columnName + * @return + * @throws NotConnectedException + * @throws SQLException + */ + protected Column getColumn(Entity entity, String columnName) { + try { + return entity == null ? null : entity.getColumn(columnName); + } catch (NotConnectedException e) { + return null; + } catch (SQLException e) { + return null; + } + } + public void init(TableRow row, TableAdapter adapter) { this.row = row; this.adapter = adapter; }