return ds.getConnection();
}
}
public void execute(DataSourceFactory connF, String vdbName, String sql) throws Exception {
Connection connection = connF.getConnection(vdbName);
try {
connection.getMetaData();
Statement statement = connection.createStatement();
boolean hasResults = statement.execute(sql);
if (hasResults) {
ResultSet results = statement.getResultSet();
ResultSetMetaData metadata = results.getMetaData();
int columns = metadata.getColumnCount();
while(results.next()) {
for (int i = 0; i < columns; i++) {
System.out.print(results.getString(i+1));
System.out.print(",");
}
System.out.println("");
}
System.out.println("Done getting results!");
results.close();
}
else {
System.out.println("update count is="+statement.getUpdateCount());
}
statement.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.close();
}
}
}