当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteConfig.setReadOnly方法代码示例

本文整理汇总了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());
        }
    }
}
 
开发者ID:udger,项目名称:udger-java,代码行数:19,代码来源:UdgerParser.java

示例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);
    }
}
 
开发者ID:iandees,项目名称:josm-mbtiles,代码行数:18,代码来源:MbTilesUtils.java

示例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;
}
 
开发者ID:hdijkema,项目名称:JNDbm,代码行数:15,代码来源:SQLiteConn.java

示例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());
}
 
开发者ID:psidnell,项目名称:ofexport2,代码行数:7,代码来源:SQLiteDataSource.java


注:本文中的org.sqlite.SQLiteConfig.setReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。