我需要一种查看preparedStatement 以进行调试的方法,这是我希望将preparedStatement 打印到控制台的Java 代码。
public class UnitTestDMUtility_Select {
@Test
public void testQUERY_CHECKBOTHPARTS() throws Exception{
UnitTestHelper helper = new UnitTestHelper();
Connection con = helper.getConnection(helper.sourceDBUrl);
Connection conTarget = helper.getConnection(helper.targetDBUrl);
PreparedStatement stmt = con.prepareStatement(DMUtility.QUERY_CHECKBOTHPARTS);
stmt.setInt(1, 101);
ResultSet sourceVal = stmt.executeQuery();
//Here is the QUERY
//select count(*) from tr_demand where demandtypeid=101
stmt = conTarget.prepareStatement(DMUtility.QUERY_CHECKBOTHPARTS);
stmt.setInt(1, 101);
ResultSet targetVal = stmt.executeQuery();
assertTrue(helper.resultSetsEqual2(sourceVal,targetVal));
}
}