I am wondering what the input parameters are referencing in the setNull and setInt methods in the following snippet. What is the parameter index. What is the SQL type and how do I determine that from the database columns/data??
public void testQUERY_UPDATEPORTFOLIO() throws Exception{
UnitTestHelper helper = new UnitTestHelper();
Connection con = helper.getConnection(helper.sourceDBUrl);
Connection conTarget = helper.getConnection(helper.targetDBUrl);
PreparedStatement stmt = con.prepareStatement(TRScheduleStatusCalculator.QUERY_UPDATEPORTFOLIO);
stmt.setNull(1,Types.INTEGER);
stmt.setInt(2,2290);
ResultSet sourceVal = stmt.executeQuery();
stmt = conTarget.prepareStatement(TRScheduleStatusCalculator.QUERY_UPDATEPORTFOLIO);
stmt.setNull(1,Types.INTEGER);
stmt.setInt(2,2290);
ResultSet targetVal = stmt.executeQuery();
assertTrue(helper.resultSetsEqual(sourceVal,targetVal));
}
PreparedStatement.setnull(paraIndex, SQLType) sets the SQL varchar type to Null for the specified placeholder.
stmt.setInt(2,2290); sets an int value 2290 at 2nd placeholder .