Java Code Examples for org.sqlite.SQLiteDataSource#setUrl()

The following examples show how to use org.sqlite.SQLiteDataSource#setUrl() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: sylph   File: SqliteDbJobStore.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public SqliteDbJobStore(
        ServerMainConfig config,
        JobEngineManager runnerManger
)
{
    this.config = requireNonNull(config, "server config is null");
    this.runnerManger = requireNonNull(runnerManger, "runnerManger config is null");

    SQLiteDataSource dataSource = new SQLiteDataSource();
    dataSource.setUrl("jdbc:sqlite:data/data.db");
    this.queryRunner = new QueryRunner(dataSource);
    this.dataSource = dataSource;
}
 
Example 2
public ScoreDatabaseAccessor(String path) throws ClassNotFoundException {
	Class.forName("org.sqlite.JDBC");
	SQLiteConfig conf = new SQLiteConfig();
	conf.setSharedCache(true);
	conf.setSynchronous(SynchronousMode.OFF);
	// conf.setJournalMode(JournalMode.MEMORY);
	SQLiteDataSource ds = new SQLiteDataSource(conf);
	ds.setUrl("jdbc:sqlite:" + path);
	qr = new QueryRunner(ds);
}
 
Example 3
public SongInformationAccessor(String filepath) throws ClassNotFoundException {
	Class.forName("org.sqlite.JDBC");
	SQLiteConfig conf = new SQLiteConfig();
	conf.setSharedCache(true);
	conf.setSynchronous(SynchronousMode.OFF);
	// conf.setJournalMode(JournalMode.MEMORY);
	ds = new SQLiteDataSource(conf);
	ds.setUrl("jdbc:sqlite:" + filepath);
	qr = new QueryRunner(ds);
	createTable();
}
 
Example 4
public SQLiteSongDatabaseAccessor(String filepath, String[] bmsroot) throws ClassNotFoundException {
	Class.forName("org.sqlite.JDBC");
	SQLiteConfig conf = new SQLiteConfig();
	conf.setSharedCache(true);
	conf.setSynchronous(SynchronousMode.OFF);
	// conf.setJournalMode(JournalMode.MEMORY);
	ds = new SQLiteDataSource(conf);
	ds.setUrl("jdbc:sqlite:" + filepath);
	qr = new QueryRunner(ds);
	root = Paths.get(".");
	createTable();
}
 
Example 5
public ScoreLogDatabaseAccessor(String path) throws ClassNotFoundException {
	Class.forName("org.sqlite.JDBC");
	SQLiteConfig conf = new SQLiteConfig();
	conf.setSharedCache(true);
	conf.setSynchronous(SynchronousMode.OFF);
	// conf.setJournalMode(JournalMode.MEMORY);
	ds = new SQLiteDataSource(conf);
	ds.setUrl("jdbc:sqlite:" + path);
	qr = new QueryRunner(ds);
	createTable();		
}
 
Example 6
Source Project: cqengine   File: OffHeapPersistence.java    License: Apache License 2.0 5 votes vote down vote up
protected OffHeapPersistence(SimpleAttribute<O, A> primaryKeyAttribute, Properties overrideProperties) {
    Properties effectiveProperties = new Properties(DEFAULT_PROPERTIES);
    effectiveProperties.putAll(overrideProperties);
    SQLiteConfig sqLiteConfig = new SQLiteConfig(effectiveProperties);
    SQLiteDataSource sqLiteDataSource = new SQLiteDataSource(sqLiteConfig);
    String instanceName = "cqengine_" + INSTANCE_ID_GENERATOR.incrementAndGet();
    sqLiteDataSource.setUrl("jdbc:sqlite:file:" + instanceName + "?mode=memory&cache=shared");

    this.primaryKeyAttribute = primaryKeyAttribute;
    this.instanceName = instanceName;
    this.sqLiteDataSource = sqLiteDataSource;
    this.persistentConnection = getConnectionInternal(null, noQueryOptions());
}
 
Example 7
Source Project: cqengine   File: DiskPersistence.java    License: Apache License 2.0 5 votes vote down vote up
protected DiskPersistence(SimpleAttribute<O, A> primaryKeyAttribute, File file, Properties overrideProperties) {
    Properties effectiveProperties = new Properties();
    effectiveProperties.putAll(DEFAULT_PROPERTIES);
    effectiveProperties.putAll(overrideProperties);
    SQLiteConfig sqLiteConfig = new SQLiteConfig(effectiveProperties);
    SQLiteDataSource sqLiteDataSource = new SQLiteDataSource(sqLiteConfig);
    sqLiteDataSource.setUrl("jdbc:sqlite:file:" + file);

    this.primaryKeyAttribute = primaryKeyAttribute;
    this.file = file.getAbsoluteFile();
    this.sqLiteDataSource = sqLiteDataSource;

    boolean openPersistentConnection = "true".equals(effectiveProperties.getProperty("persistent_connection")); //default false
    boolean useSharedCache = "true".equals(effectiveProperties.getProperty("shared_cache")); // default false
    boolean useReadWriteLock = !"false".equals(effectiveProperties.getProperty("use_read_write_lock")); // default true
    if (useSharedCache) {
        // If shared_cache mode is enabled, by default we also use a read-write lock,
        // unless using the read-write lock has been explicitly disabled...
        sqLiteDataSource.setUrl("jdbc:sqlite:file:" + file + "?cache=shared");
        this.useReadWriteLock = useReadWriteLock;
    }
    else {
        // If we are not using shared_cache mode, we never use a read-write lock...
        sqLiteDataSource.setUrl("jdbc:sqlite:file:" + file);
        this.useReadWriteLock = false;
    }
    if (useSharedCache || openPersistentConnection) {
        // If shared_cache is enabled, we always open a persistent connection regardless...
        this.persistentConnection = getConnectionWithoutRWLock(null, noQueryOptions());
    }
}
 
Example 8
Source Project: cqengine   File: OffHeapPersistenceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualsAndHashCode() {
    SQLiteDataSource ds1 = new SQLiteDataSource(new SQLiteConfig());
    ds1.setUrl("foo");
    SQLiteDataSource ds2 = new SQLiteDataSource(new SQLiteConfig());
    ds2.setUrl("bar");
    EqualsVerifier.forClass(OffHeapPersistence.class)
            .withIgnoredFields("sqLiteDataSource", "persistentConnection", "closed", "readWriteLock")
            .suppress(Warning.NULL_FIELDS, Warning.STRICT_INHERITANCE)
            .withPrefabValues(SQLiteDataSource.class, ds1, ds2)
            .verify();
}
 
Example 9
Source Project: cqengine   File: DiskPersistenceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualsAndHashCode() {
    SQLiteDataSource ds1 = new SQLiteDataSource(new SQLiteConfig());
    ds1.setUrl("foo");
    SQLiteDataSource ds2 = new SQLiteDataSource(new SQLiteConfig());
    ds2.setUrl("bar");
    EqualsVerifier.forClass(DiskPersistence.class)
            .withIgnoredFields("sqLiteDataSource", "persistentConnection", "closed", "useReadWriteLock", "readWriteLock")
            .suppress(Warning.NULL_FIELDS, Warning.STRICT_INHERITANCE)
            .withPrefabValues(SQLiteDataSource.class, ds1, ds2)
            .verify();
}
 
Example 10
Source Project: cqengine   File: TemporaryDatabase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void before() {
    try {
        super.before();
        dbFile = newFile();
        url = "jdbc:sqlite:" + dbFile.getAbsolutePath();
        dataSource = new SQLiteDataSource(config);
        dataSource.setUrl(url);
    }
    catch (Throwable throwable) {
        throw new IllegalStateException(throwable);
    }
}
 
Example 11
@Override
protected DataSource createDataSource(String jdbcUrl) {
	SQLiteDataSource ds = new SQLiteDataSource();
	ds.setUrl(jdbcUrl);
	return ds;
}
 
Example 12
/**
 * Create a pooled datasource for the application.
 * <p>
 * Default sqlite database does not work with a connection pool, actually
 * most embedded databases do not, hence returning native implementation for
 * default db.
 */
@Override
public DataSource get() {
  SQLiteDataSource ds = new SQLiteDataSource();
  ds.setUrl(configuration.getJdbcUrl());
  return ds;
}