本文整理汇总了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);
}
}
示例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");
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}