public class SqliteJdbcMailbox extends Mailbox.Default {
private Connection conn;
- private static final String columns = "messageid_,from_,to_,date_,subject_,headers_,body_,flags_";
+ private static final String columns =
+ " messageid_, from_,to_,date_,subject_,headers_,body_,flags_";
+
+ /**
+ * from http://www.sqlite.org/autoinc.html
+ * "If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT
+ * then a slightly different ROWID selection algorithm is
+ * used. The ROWID chosen for the new row is one larger than the
+ * largest ROWID that has ever before existed in that same
+ * table. If the table has never before contained any data, then
+ * a ROWID of 1 is used. If the table has previously held a row
+ * with the largest possible ROWID, then new INSERTs are not
+ * allowed and any attempt to insert a new row will fail with an
+ * SQLITE_FULL error.
+ */
+ private static final String columns_ =
+ "uid_ INTEGER PRIMARY KEY AUTOINCREMENT, messageid_ unique,from_,to_,date_,subject_,headers_,body_,flags_";
public SqliteJdbcMailbox(String filename) {
try {
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:"+filename);
- conn.prepareStatement("create virtual table if not exists "+
- "'mail' using FTS2("+columns+",PRIMARY KEY(messageid_))").executeUpdate();
+ conn.prepareStatement("create virtual table if not exists 'mail' using FTS2("+columns_+")").executeUpdate();
}
catch (SQLException e) { throw new RuntimeException(e); }
catch (ClassNotFoundException e) { throw new RuntimeException(e); }