I have come across the following codes i feel it is doing the wrong thing:
(Note that this is JDK 1.4.2, therefore the list is not typed)
StringBuffer queryBuffer = new StringBuffer();
ArrayList temp = new ArrayList();
...
queryBuffer.append("and sb.POSTCODE = ? ");
temp.add(postcode);
...
conn = ConnectionManager.getConnection();
pstmt = conn.prepareStatement(queryBuffer.toString());
This is what i am concerned about:
for(int i=0; i<temp.size(); i++) {
log.debug("setString("+ (i+1) + "," + (String)temp.get(i) + ")");
pstmt.setString(i+1, (String)temp.get(i));
}
But i have noted that some of the corresponding data types (field) in the database are integer, and dates, would this be alright?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…