//자바에서 SQL에 인자 형태로 값전달
private int getXNum(String s, String table)
{
try {
String squery = "select num from " + table + " where name = ?";
PreparedStatement spstmt = null;
spstmt = con.prepareStatement(squery);
spstmt.setString(1, s);
rs = spstmt.executeQuery();
if (rs.next()) {
return rs.getInt("num");
}
} catch (Exception e) {
// TODO: handle exception
e. printStackTrace();
}
return -1;
}
댓글 없음:
댓글 쓰기