try {
dataSourceConnection = dataSource.getConnection();
sqlStatement = dataSourceConnection.createStatement();
}
catch (SQLException e) {
throw new AlgorithmExecutionException(e);
}
String sqlStatementString = null;
// Attempt to form our SQL query and update.
try {
sqlStatementString = formSQL();
}
catch (SQLFormationException sqlFormationException) {
throw new AlgorithmExecutionException(sqlFormationException);
}
// Success at this point (with forming the SQL), so execute it if it is not
// empty.
if (!sqlStatement.equals("")) {
try {
// If execute returns true, there is at least one result set. So,
// let's get those and turn them into data sources for our out-data
// YAY!
if (sqlStatement.execute(sqlStatementString)) {
// Used to store the list of
// result-sets-converted-to-new-databases that we're working on.
ArrayList resultSetsConvertedToNewDatabases = new ArrayList();
do {
// Get the current result set.
ResultSet resultSet = sqlStatement.getResultSet();
// Construct the new database out of the result set.
DataSource newDatabase = null;
/* try {
newDatabase = null;
// this.databaseService.createDatabase(resultSet);
}
catch (DatabaseCreationException e) {
throw new AlgorithmExecutionException(e);
} */
// Wrap the new database.
Data newDatabaseData = createOutDataFromDataSource(newDatabase);
// Add the new out-data entry to our working list.
resultSetsConvertedToNewDatabases.add(newDatabaseData);
}
while (sqlStatement.getMoreResults());
// Convert the ArrayList to a Data[].
Data[] finalResultSetsConvertedToNewDatabasesData =
new Data[resultSetsConvertedToNewDatabases.size()];
finalResultSetsConvertedToNewDatabasesData =
(Data[])resultSetsConvertedToNewDatabases.toArray
(finalResultSetsConvertedToNewDatabasesData);
return manipulateFinalOutData
(finalResultSetsConvertedToNewDatabasesData);
}
}
catch (SQLException sqlException) {
throw new AlgorithmExecutionException(sqlException);
}
}
//
return null;