}
private void executeSQLWithDataStoreConnection() {
String schema = getPMFProperty("javax.jdo.mapping.Schema");
String sql = "SELECT X, Y FROM " + schema + ".PCPoint";
JDOConnection jconn = null;
try {
getPM().currentTransaction().begin();
jconn = pm.getDataStoreConnection();
Connection conn = (Connection)jconn;
if (conn.getAutoCommit()) {
appendMessage(ASSERTION_FAILED +
"Autocommit must not be true in JDO connection.");
};
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
Collection actuals = new HashSet();
while (rs.next()) {
PCPoint p = new PCPoint(rs.getInt(1), rs.getInt(2));
actuals.add(p);
}
if (actuals.size() != 1) {
appendMessage(ASSERTION_FAILED + "Wrong size of result of " +
sql + NL + "expected: 1, actual: " + actuals.size());
} else {
PCPoint actual = (PCPoint)actuals.iterator().next();
if (goldenPoint.getX() != actual.getX() ||
!goldenPoint.getY().equals(actual.getY())) {
appendMessage(ASSERTION_FAILED +
"Wrong values of PCPoint from SQL" +
"expected x: " + goldenPoint.getX() +
", y: " + goldenPoint.getX() + NL +
"actual x: " + actual.getX() +
", y: " + actual.getX()
);
}
}
} catch (Exception ex) {
appendMessage(ASSERTION_FAILED + " caught exception:" + ex);
} finally {
jconn.close();
getPM().currentTransaction().commit();
failOnError();
}
}