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


Java SQLiteConfig.enforceForeignKeys方法代码示例

本文整理汇总了Java中org.sqlite.SQLiteConfig.enforceForeignKeys方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteConfig.enforceForeignKeys方法的具体用法?Java SQLiteConfig.enforceForeignKeys怎么用?Java SQLiteConfig.enforceForeignKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sqlite.SQLiteConfig的用法示例。


在下文中一共展示了SQLiteConfig.enforceForeignKeys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ResultsDatabase

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public ResultsDatabase(String resultsDatabaseLocation) {

        if (!new File(resultsDatabaseLocation).exists()) {
            throw new RuntimeException("Results database file \"" + resultsDatabaseLocation + "\" does not exist");
        }

        try {
            Class.forName("org.sqlite.JDBC");

            // enforce the foreign keys that are specified in the
            // relational schema; this could be turned off if you are
            // debugging and the data generation subsystem is not yet
            // generating data to satisfy the constraints.
            SQLiteConfig config = new SQLiteConfig();
            config.enforceForeignKeys(true);

            // create the connection to the database,
            // using the properties for the SQLiteConfig
            // object to handle referential integrity's on/off switch
            connection = DriverManager.getConnection("jdbc:sqlite:" + resultsDatabaseLocation, config.toProperties());

        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:schemaanalyst,项目名称:schemaanalyst,代码行数:26,代码来源:ResultsDatabase.java

示例2: connect

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public void connect() {
	try {
		Class.forName("org.sqlite.JDBC");
		connection = DriverManager.getConnection("jdbc:sqlite:" + DBPath);

		statement = connection.createStatement();
		System.out.println("Connexion � " + DBPath + " avec succ�s");

		SQLiteConfig config = new SQLiteConfig();  
		config.enforceForeignKeys(true);  
		connection = DriverManager.getConnection("jdbc:sqlite:" + DBPath,config.toProperties());

	} catch (ClassNotFoundException notFoundException) {
		notFoundException.printStackTrace();
		System.out.println("Erreur de connexion");
	} catch (java.sql.SQLException sqlException) {
		sqlException.printStackTrace();
		System.out.println("Erreur de connexion");
	}
}
 
开发者ID:Kaysoro,项目名称:carnet-chasse-otomai,代码行数:21,代码来源:Connexion.java

示例3: getConnection

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * @return Database connection.
 * @throws ClassNotFoundException Exception while trying to use JDBC driver
 * @throws SQLException           Exception while trying to connect to
 *                                database
 * @throws ExceptionHandler       Exception while accessing config directory
 */
public static Connection getConnection()
        throws ClassNotFoundException, SQLException, ExceptionHandler {
    if (DB_FILE.getParentFile().exists()
            || DB_FILE.getParentFile().mkdirs()) {
        if (!DB_FILE.exists()) {
            try {
                Config.setValue(Config.PROP_SCHEMA_VERSION,
                        String.valueOf(SCHEMA_VERSION));
            } catch (IOException e) {
                ExceptionDialog.show(e);
                LOGGER.error(e);
                e.printStackTrace();
            }
        }
        Class.forName(DRIVER);
        SQLiteConfig config = new SQLiteConfig();
        config.enforceForeignKeys(true);
        return DriverManager.getConnection(DB_URL, config.toProperties());
    } else {
        throw new ExceptionHandler(Error.DB_CONNECTION);
    }

}
 
开发者ID:Alkisum,项目名称:YTSubscriber,代码行数:31,代码来源:Database.java

示例4: open

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public void open() throws StoreException {
  try {
    SQLiteConfig config = new SQLiteConfig();

    // Disable fsync calls, trusting that the filesystem will do the right thing. It's not always
    // the best assumption, but we are file with losing ~1 day of data (basically, the time
    // between backups). Additionally, switch to write-ahead-logging for the journal. We could
    // turn it off completely as well, and rely on backups in the event of data loss, but that's
    // slightly more painful for development (where "crashes" are more likely).
    config.setSynchronous(SQLiteConfig.SynchronousMode.OFF);
    config.setJournalMode(SQLiteConfig.JournalMode.WAL);

    // Increase the cache size, we have plenty of memory on the server.
    config.setCacheSize(2048);

    // Enforce foreign key constraints (for some reason, the default is off)
    config.enforceForeignKeys(true);

    dataSource = new SQLiteConnectionPoolDataSource(config);
    dataSource.getPooledConnection();
    dataSource.setUrl("jdbc:sqlite:data/store/" + fileName);
  } catch(SQLException e) {
    throw new StoreException(e);
  }
  ensureVersion();
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:27,代码来源:BaseStore.java

示例5: getConnection

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
private static Connection getConnection() throws SQLException {
    SQLiteConfig config = new SQLiteConfig();
    config.enforceForeignKeys(true);
    SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
    dataSource.setUrl("jdbc:sqlite:" + DATABASE.getAbsolutePath().replace("\\", "/"));
    dataSource.setConfig(config);
    return dataSource.getConnection();
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:9,代码来源:SQL.java

示例6: initializeDatabaseConnection

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * Initialize the connection to the SQLite database.
 */
@Override
public void initializeDatabaseConnection() {
    try {
        Class.forName(databaseConfiguration.getSqliteDriver());
        LOGGER.log(Level.FINE, "Loading SQLite driver: {0}", databaseConfiguration.getSqliteDriver());

        File sqliteDirectory = new File(locationConfiguration.getDatabaseDir()
                + File.separator + databaseConfiguration.getSqlitePath());
        if (sqliteDirectory.exists()) {
            LOGGER.log(Level.CONFIG, "Database folder already exists: {0}", sqliteDirectory.getPath());
        }
        Files.createDirectories(sqliteDirectory.toPath());

        String databaseUrl;
        if (!databaseConfiguration.getSqliteInMemory()) {
            databaseUrl = "jdbc:sqlite:" + sqliteDirectory.getAbsolutePath() + File.separator + databaseName;
        } else {
            databaseUrl = "jdbc:sqlite::memory:";
        }
        LOGGER.log(Level.FINE, "JDBC Connection URL: {0}", databaseUrl);

        // enforce the foreign keys that are specified in the
        // relational schema; this could be turned off if you are
        // debugging and the data generation subsystem is not yet
        // generating data to satisfy the constraints.
        SQLiteConfig config = new SQLiteConfig();
        config.enforceForeignKeys(true);

        // create the connection to the database,
        // using the properties for the SQLiteConfig
        // object to handle referential integrity's on/off switch
        connection = DriverManager.getConnection(databaseUrl, config.toProperties());

        initialized = true;
    } catch (ClassNotFoundException | IOException | SQLException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:schemaanalyst,项目名称:schemaanalyst,代码行数:42,代码来源:SQLiteDatabaseInteractor.java

示例7: init

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
public static boolean init() {
    try {
        Class.forName("org.sqlite.JDBC");
        SQLiteConfig config = new SQLiteConfig();
        config.enforceForeignKeys(true);
        c = DriverManager.getConnection("jdbc:sqlite:GVol.db", config.toProperties());
    } catch (Exception ex) {
        return false;
    }
    return true;
}
 
开发者ID:eg-cert,项目名称:GVol,代码行数:12,代码来源:DatabaseConn.java

示例8: createConnection

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * @return A new connection to the Photo Flow SQLite database.
 * @throws SQLException When a connection could not be created.
 */
private Connection createConnection() throws SQLException {
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);

	try {
		this.connection = DriverManager.getConnection(DB_BASE_URL + FileHandler.sqliteFile(), config.toProperties());
	} catch (FileHandlerException e) {
		throw new RuntimeException(e);
	}
	return connection;
}
 
开发者ID:chilloutman,项目名称:photo-flow,代码行数:16,代码来源:SQLiteConnectionProvider.java

示例9: SegmentDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public SegmentDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractSegmentDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:SegmentDAO.java

示例10: CloudDCDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public CloudDCDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractCloudDCDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:CloudDCDAO.java

示例11: TunnelDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public TunnelDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractTunnelDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:TunnelDAO.java

示例12: DARouterDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public DARouterDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractDARouterDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:DARouterDAO.java

示例13: DC2DCCommunicationDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public DC2DCCommunicationDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractDC2DCCommunicationDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:DC2DCCommunicationDAO.java

示例14: PrefixDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public PrefixDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractPrefixDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:PrefixDAO.java

示例15: ISPDAO

import org.sqlite.SQLiteConfig; //导入方法依赖的package包/类
/**
 * The constructor.
 */
public ISPDAO() {
	Properties connectionProperties = new Properties();
	SQLiteConfig config = new SQLiteConfig();
	config.enforceForeignKeys(true);
	connectionProperties = config.toProperties(); 
	DBI dbi = new DBI(DbConstants.DBI_URL, connectionProperties);
	dao = dbi.onDemand(AbstractISPDAO.class);
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:12,代码来源:ISPDAO.java


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