norm icon indicating copy to clipboard operation
norm copied to clipboard

how it initialize for sqlite

Open GF-Huang opened this issue 9 years ago • 4 comments

sqlite do not need localhost System.setProperty("norm.serverName", "localhost");

GF-Huang avatar May 03 '16 17:05 GF-Huang

Ok. Does it work for sqllite otherwise?

ccleve avatar May 03 '16 17:05 ccleve

never try other, because i'm using sqlite and i must use it in my environment.

GF-Huang avatar May 03 '16 18:05 GF-Huang

No, what I mean is, does it work ok for sqllite? Are you having any problems?

On Tue, May 3, 2016 at 1:28 PM, Great Fire Wall [email protected] wrote:

never try other, because i'm using sqlite and i must use it in my environment.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/dieselpoint/norm/issues/12#issuecomment-216621635

ccleve avatar May 03 '16 18:05 ccleve

it's not work for sqlite. but I see https://github.com/brettwooldridge/HikariCP/issues/393, and make my code like this, it work fine. code:

import com.dieselpoint.norm.Database;

public final class Db extends Database {
    @Override
    protected DataSource getDataSource() throws SQLException {
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("org.sqlite.JDBC");
        config.setJdbcUrl("jdbc:sqlite:file.db");
        config.setConnectionTestQuery("SELECT 1");
        config.setMaximumPoolSize(100);
        config.setInitializationFailFast(true); // optional

        return new HikariDataSource(config);
    }
}

main here:
    Db db = new Db();
    db.getConnection();  // work fine, and file.db will create.

GF-Huang avatar May 03 '16 18:05 GF-Huang