use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBTableSelectorNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
exec.setMessage("Retrieving metadata from database");
DatabaseConnectionPortObject incomingConnection = (DatabaseConnectionPortObject) inObjects[0];
DatabaseConnectionSettings connSettings = incomingConnection.getConnectionSettings(getCredentialsProvider());
String sql = FlowVariableResolver.parse(m_settings.getQuery(), this);
DatabaseQueryConnectionSettings querySettings = new DatabaseQueryConnectionSettings(connSettings, sql);
DBReader conn = querySettings.getUtility().getReader(querySettings);
try {
DataTableSpec tableSpec = conn.getDataTableSpec(getCredentialsProvider());
return new PortObject[] { new DatabasePortObject(new DatabasePortObjectSpec(tableSpec, querySettings)) };
} catch (SQLException ex) {
Throwable cause = ExceptionUtils.getRootCause(ex);
if (cause == null) {
cause = ex;
}
throw new InvalidSettingsException("Error while validating SQL query: " + cause.getMessage(), ex);
}
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBGroupByNodeModel2 method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
final DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObject.getSpec(), false));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class ParameterizedDBQueryNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
final BufferedDataTable inTable = (BufferedDataTable) inData[0];
final DatabasePortObject dbObject = (DatabasePortObject) inData[1];
DatabaseQueryConnectionSettings conn = dbObject.getConnectionSettings(getCredentialsProvider());
final String newQuery = parseSQLStatement(inTable.getDataTableSpec(), conn.getQuery());
conn = createDBQueryConnection(dbObject.getSpec(), newQuery);
final DBReader reader = conn.getUtility().getReader(conn);
final DataTableRowInput data = new DataTableRowInput(inTable);
final BufferedDataTable outTable = reader.loopTable(exec, getCredentialsProvider(), data, inTable.size(), m_failIfExceptionModel.getBooleanValue(), m_appendInputColumnsModel.getBooleanValue(), m_includeEmptyResultsModel.getBooleanValue(), m_retainAllColumnsModel.getBooleanValue(), m_dataColumns.toArray(new String[m_dataColumns.size()])).getDataTable();
final BufferedDataTable errorTable = reader.getErrorDataTable();
return new BufferedDataTable[] { outTable, errorTable };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBSamplingNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
final DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObject.getSpec(), exec, false));
return new PortObject[] { outObject };
}
Aggregations