import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
if (_context == null) {
_context = new ClassPathXmlApplicationContext(
(String[]) _configLocations, _parentContext);
- assertNotNull(_context);
}
return _context;
}
}
/**
- * Executes an SQL query within a transaction.
+ * Executes an SQL query.
*
* @param aSql
* Query to execute.
}
/**
- * Executes a query within a transaction. See
+ * Executes a query. See
* {@link #setPreparedParam(int, PreparedStatement, Object)}for details on
* supported argument types.
*
* @return Result set.
*/
public ResultSet executeQuery(final String aSql, final Object[] aArgs) {
- Map results = executeTransaction(new TestTransactionCallback() {
- public Map execute() throws Exception {
- Connection connection = getConnection();
-
- PreparedStatement statement = connection.prepareStatement(aSql);
- setPreparedParams(aArgs, statement);
+ try {
+ Connection connection = getConnection();
- ResultSet resultSet = statement.executeQuery();
- TreeMap results = new TreeMap();
- results.put("resultSet", resultSet);
+ PreparedStatement statement = connection.prepareStatement(aSql);
+ setPreparedParams(aArgs, statement);
- return results;
- }
- });
-
- return (ResultSet) results.get("resultSet");
+ return statement.executeQuery();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
}
/**
* @return
* @throws SQLException
*/
- protected int getTableSize(String aTable) throws SQLException {
+ protected int getTableSize(final String aTable) throws SQLException {
+
ResultSet resultSet = executeQuery("select * from " + aTable);
int count = 0;
while (resultSet.next()) {
count++;
}
-
return count;
}