
com.github.gkutiel.FlipLoggerDb Maven / Gradle / Ivy
The newest version!
package com.github.gkutiel;
import org.h2.Driver;
import com.github.gkutiel.flip.db.FlipDB;
import com.github.gkutiel.flip.db.Indexs;
import com.github.gkutiel.flip.db.Indexs.Index;
import com.github.gkutiel.flip.db.Query;
import com.github.gkutiel.flip.db.Table;
public class FlipLoggerDb {
@Indexs(@Index({ "key", "time" }))
public static class Log implements Table {
public long time;
public String key;
public String val;
}
public interface LogDb {
@Query("SELECT * FROM Log WHERE key = ? AND time > ?")
public Log[] get(String key, long minTime);
@Query("SELECT DISTINCT key FROM Log")
public String[] getKeys();
@Query("INSERT INTO Log VALUES(?,?,?)")
public void log(long time, String key, String val);
}
private static final FlipDB FLIP_DB = new FlipDB(new Driver(), "jdbc:h2:db/log");
static final LogDb LOG_DB = FLIP_DB.getImplementation(LogDb.class);
static {
FLIP_DB.createTables(Log.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy