1 回答

TA貢獻1802條經(jīng)驗 獲得超5個贊
你uploadPubList()為什么要迭代pubList.getPubs()?
您只想插入 1 行:城鎮(zhèn)名稱、郵政編碼區(qū)域和酒吧數(shù)量,對吧?
另外,這一行:
insertPub(pubList, pub);
它有什么作用?
刪除for循環(huán)并保留這些:
public void uploadPubList(PubList pubList){
String sql = "INSERT OR REPLACE INTO main.PubLists(Town,PostCodeArea,NumberOfPubs) VALUES(?,?,?)";
try {
Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, pubList.getName());
pstmt.setString(2, pubList.getPostCodeArea());
pstmt.setInt(3, pubList.getPubs().size());
pstmt.executeUpdate();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
從設(shè)備上卸載應(yīng)用程序,以便刪除并重新運行數(shù)據(jù)庫。
添加回答
舉報