0
我需要一種方法來查看preparedStatement的調試,這裏是我的java代碼,我希望將prepareStatement打印到控制檯。有沒有什麼辦法打印準備好的語句到控制檯System.out.println
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));
}
}
爲什麼不設置一個破發點,並讀出的值? – Max
請告訴我更多。我不知道這一點。 – Croeber
你以前從未在IDE中調試過嗎?我假設你正在使用eclipse,但是,其他IDE有很多教程。 http://www.vogella.com/articles/EclipseDebugging/article.html#usedebug_breakpoints – Max