62,623
社区成员
发帖
与我相关
我的任务
分享
public int getCourseid(String g_year, String c_name, int x_id){
int c_id = 0;
String sql = "select c_id from courses where year = '" + g_year + "'and c_name = '" + c_name + "'and x_id = '" + x_id + "';";
try {
stmt = (Statement) conn.createStatement();
rs = (ResultSet) stmt.executeQuery(sql);---------------------------结果集为空,为什么?
while(rs.next()){
c_id = Integer.parseInt(rs.getString("c_id"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return c_id;
}