本文整理汇总了Java中org.sqlite.SQLiteConfig.setReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteConfig.setReadOnly方法的具体用法?Java SQLiteConfig.setReadOnly怎么用?Java SQLiteConfig.setReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sqlite.SQLiteConfig
的用法示例。
在下文中一共展示了SQLiteConfig.setReadOnly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
private void connect() throws SQLException {
if (connection == null) {
SQLiteConfig config = new SQLiteConfig();
config.setReadOnly(true);
if (inMemoryEnabled) {
// we cannot use read only for in memory DB since we need to populate this DB from the file.
connection = DriverManager.getConnection("jdbc:sqlite::memory:");
File dbfile = new File(parserDbData.dbFileName);
try (Statement statement = connection.createStatement()) {
statement.executeUpdate("restore from " + dbfile.getPath());
} catch (Exception e) {
LOG.warning("Error re-constructing in memory data base from Db file " + dbfile);
}
} else {
connection = DriverManager.getConnection("jdbc:sqlite:" + parserDbData.dbFileName, config.toProperties());
}
}
}
示例2: obtainSqliteDbConnection
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public static Connection obtainSqliteDbConnection(File dbFile, boolean readOnly) throws MbtilesException {
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e1) {
throw new MbtilesException("Could not load sqlite driver.", e1);
}
Connection connection = null;
try {
SQLiteConfig config = new SQLiteConfig();
config.setReadOnly(readOnly);
connection = DriverManager.getConnection("jdbc:sqlite:" + dbFile.getAbsolutePath(), config.toProperties());
return connection;
} catch (SQLException e) {
throw new MbtilesException("Could not connect to sqlite database.", e);
}
}
示例3: newConn
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public Connection newConn() throws NDbmException {
String dbname=_db_location.getAbsolutePath();
Connection myconn;
try {
SQLiteConfig c = new SQLiteConfig();
c.setReadOnly(_readonly);
String sqliteurl="jdbc:sqlite:"+dbname+".db";
myconn=DriverManager.getConnection(sqliteurl, c.toProperties());
} catch (Exception E) {
myconn=null;
throw new NDbmException(E);
}
return myconn;
}
示例4: getConnection
import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
@Override
public Connection getConnection() throws SQLException {
final SQLiteConfig config = new SQLiteConfig();
config.setReadOnly(this.readOnly);
return DriverManager.getConnection(getDriverURL(), config.toProperties());
}