line break
[org.ibex.mail.git] / src / org / ibex / mail / Graylist.java
index 0628062..a23581e 100644 (file)
@@ -7,21 +7,13 @@ import java.io.*;
 import java.util.*;
 import java.sql.Timestamp;
 
-public class Graylist {
+public class Graylist extends SqliteDB {
 
-    private Connection conn;
-
-    public Graylist(String filename) {
-        try {
-            Class.forName("org.sqlite.JDBC");
-            conn = DriverManager.getConnection("jdbc:sqlite:"+filename);
-            conn.prepareStatement("create table if not exists "+
-                                  "'whitelist' (ip unique)").executeUpdate();
-            conn.prepareStatement("create table if not exists "+
-                                  "'graylist' (ip,fromaddr,toaddr,date, primary key(ip,fromaddr,toaddr))").executeUpdate();
-        }
-        catch (SQLException e) { throw new RuntimeException(e); }
-        catch (ClassNotFoundException e) { throw new RuntimeException(e); }
+    public Graylist(String filename) throws SQLException {
+        super(filename);
+        SqliteTable whitelist = getTable("whitelist", "(ip unique)");
+        SqliteTable graylist  = getTable("graylist",  "(ip,fromaddr,toaddr,date,PRIMARY KEY(ip,fromaddr,toaddr))");
+        graylist.reap("date");
     }
 
     public synchronized void addWhitelist(InetAddress ip) {