X-Git-Url: https://harishankar.org/repos/?p=habeas.git;a=blobdiff_plain;f=src%2Fhabeas%2FUtility.java;h=8b27e7ea33589528aa2fe032a461d76b22909ee2;hp=3eabd875efad444d5c9b3c097a37df3bd2ca66bf;hb=9a41ac52640b4316b9b69817cb4bc1298d0bd749;hpb=3d2f6cfab3becbf7ad69924e63b91fa7e2745fc7 diff --git a/src/habeas/Utility.java b/src/habeas/Utility.java index 3eabd87..8b27e7e 100644 --- a/src/habeas/Utility.java +++ b/src/habeas/Utility.java @@ -8,11 +8,8 @@ package habeas; import java.util.ArrayList; import java.util.prefs.Preferences; import java.sql.*; -import java.util.Dictionary; -import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.JOptionPane; /** * @@ -116,6 +113,31 @@ 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) + return false; + try { + Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL); + PreparedStatement st = conn.prepareStatement("INSERT INTO legalnotices" + + " (ReferenceNumber, Description, EntrustmentDate, ClientId) " + + "VALUES (?, ?, ?, ?);"); + st.setString(1, reference_number); + st.setString(2, description); + st.setLong(3, entrustment_date.getTime()/1000); + st.setInt (4, client.getKey()); + st.execute(); + conn.close(); + return true; + + } catch (SQLException ex) { + Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + } public Utility () {