Search in sources :

Example 6 with SQLiteConfig

use of org.sqlite.SQLiteConfig in project quorrabot by GloriousEggroll.

the class SqliteStore method CreateConnection.

private static Connection CreateConnection(String dbname, int cache_size, boolean safe_write, boolean journal, boolean autocommit) {
    Connection connection = null;
    try {
        SQLiteConfig config = new SQLiteConfig();
        config.setCacheSize(cache_size);
        config.setSynchronous(safe_write ? SQLiteConfig.SynchronousMode.FULL : SQLiteConfig.SynchronousMode.NORMAL);
        config.setTempStore(SQLiteConfig.TempStore.MEMORY);
        config.setJournalMode(journal ? SQLiteConfig.JournalMode.TRUNCATE : SQLiteConfig.JournalMode.OFF);
        connection = DriverManager.getConnection("jdbc:sqlite:" + dbname.replaceAll("\\\\", "/"), config.toProperties());
        connection.setAutoCommit(autocommit);
    } catch (SQLException ex) {
        com.gmt2001.Console.err.printStackTrace(ex);
    }
    return connection;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) SQLiteConfig(org.sqlite.SQLiteConfig)

Aggregations

SQLiteConfig (org.sqlite.SQLiteConfig)6 SQLException (java.sql.SQLException)3 Connection (java.sql.Connection)2 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 IOExceptionWithCause (org.apache.commons.io.IOExceptionWithCause)1 Flyway (org.flywaydb.core.Flyway)1 DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)1 Test (org.junit.Test)1 SQLiteDataSource (org.sqlite.SQLiteDataSource)1