X-Git-Url: https://harishankar.org/repos/?p=habeas.git;a=blobdiff_plain;f=src%2Fhabeas%2FUtility.java;fp=src%2Fhabeas%2FUtility.java;h=a1148a2ac738111b25fa7beafdcdc1284350abaf;hp=8b27e7ea33589528aa2fe032a461d76b22909ee2;hb=2ec9a68e727e3b67f003b43acd8593660fc90d26;hpb=9a41ac52640b4316b9b69817cb4bc1298d0bd749 diff --git a/src/habeas/Utility.java b/src/habeas/Utility.java index 8b27e7e..a1148a2 100644 --- a/src/habeas/Utility.java +++ b/src/habeas/Utility.java @@ -118,7 +118,7 @@ public class Utility { static boolean addLegalNotice(String reference_number, String description, java.util.Date entrustment_date, DBItem client) { if ("".equals(reference_number) || "".equals(description) || - entrustment_date == null) + entrustment_date == null || client == null) return false; try { Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL); @@ -138,6 +138,27 @@ public class Utility { return false; } + } + + static ArrayList getNotices() { + ArrayList notices = new ArrayList<>(); + try { + Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL); + Statement st = conn.createStatement(); + ResultSet rs = st.executeQuery("SELECT id, ReferenceNumber, Description " + + "FROM legalnotices;"); + while (rs.next()) { + notices.add(rs.getInt("id")); + notices.add(rs.getString("ReferenceNumber")); + notices.add(rs.getString("Description")); + } + conn.close(); + return notices; + } catch (SQLException ex) { + Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + } public Utility () {