Search in sources :

Example 1 with SQLiteDataSource

use of org.sqlite.SQLiteDataSource in project GeoGig by boundlessgeo.

the class XerialConfigDatabase method connect.

SQLiteDataSource connect(Config config) {
    SQLiteDataSource dataSource = Xerial.newDataSource(config.file);
    new DbOp<Void>() {

        @Override
        protected Void doRun(Connection cx) throws IOException, SQLException {
            String sql = "CREATE TABLE IF NOT EXISTS config (section VARCHAR, key VARCHAR, value VARCHAR," + " PRIMARY KEY (section,key))";
            Statement st = open(cx.createStatement());
            st.execute(log(sql, LOG));
            sql = "CREATE INDEX IF NOT EXISTS config_section_idx ON config (section)";
            st.execute(log(sql, LOG));
            return null;
        }
    }.run(dataSource);
    return dataSource;
}
Also used : SQLiteDataSource(org.sqlite.SQLiteDataSource) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) IOException(java.io.IOException)

Example 2 with SQLiteDataSource

use of org.sqlite.SQLiteDataSource in project flyway by flyway.

the class SQLiteMigrationMediumTest method singleConnectionExternalDataSource.

@Test
public void singleConnectionExternalDataSource() {
    SQLiteConfig config = new SQLiteConfig();
    config.setJournalMode(SQLiteConfig.JournalMode.WAL);
    config.setSynchronous(SQLiteConfig.SynchronousMode.NORMAL);
    SQLiteDataSource dataSource = new SQLiteDataSource(config);
    dataSource.setUrl("jdbc:sqlite:target/single_external");
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("migration/sql");
    flyway.clean();
    flyway.migrate();
}
Also used : SQLiteDataSource(org.sqlite.SQLiteDataSource) Flyway(org.flywaydb.core.Flyway) SQLiteConfig(org.sqlite.SQLiteConfig) Test(org.junit.Test)

Example 3 with SQLiteDataSource

use of org.sqlite.SQLiteDataSource in project GeoGig by boundlessgeo.

the class Xerial method newDataSource.

public static SQLiteDataSource newDataSource(File db) {
    SQLiteDataSource dataSource = new SQLiteDataSource();
    dataSource.setUrl("jdbc:sqlite:" + db.getAbsolutePath());
    dataSource.setSynchronous(DEFAULT_SYNC_MODE.getValue());
    return dataSource;
}
Also used : SQLiteDataSource(org.sqlite.SQLiteDataSource)

Aggregations

SQLiteDataSource (org.sqlite.SQLiteDataSource)3 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 Flyway (org.flywaydb.core.Flyway)1 Test (org.junit.Test)1 SQLiteConfig (org.sqlite.SQLiteConfig)1