int bookID
返回值0
,它应返回1
。 (表格中的第一个ID。)请帮助。
public void ID(){
conn = ConnectDB();
String sql = "Select Book_ID From Student Biblio";
try {
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
if(rs.next()){
int bookID = rs.getInt(1); //IDTable
}
} catch (SQLException ex) {
Logger.getLogger(Student.class.getName()).log(Level.SEVERE, null, ex);
}
}
答案 0 :(得分:0)
而不是尝试使用while循环并检查表的行。
答案 1 :(得分:0)
试试这可能会帮助你
public void ID(){
conn = ConnectDB();
String sql = "Select Book_ID From Student Biblio";
try {
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next()){
int bookID = rs.getInt("Book_ID"); //IDTable
}
} catch (SQLException ex) {
Logger.getLogger(Student.class.getName()).log(Level.SEVERE, null, ex);
}
}