本文整理汇总了Java中org.apache.derby.jdbc.EmbeddedDataSource.setCreateDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedDataSource.setCreateDatabase方法的具体用法?Java EmbeddedDataSource.setCreateDatabase怎么用?Java EmbeddedDataSource.setCreateDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.derby.jdbc.EmbeddedDataSource
的用法示例。
在下文中一共展示了EmbeddedDataSource.setCreateDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupInitialContext
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
protected static void setupInitialContext() throws Exception {
if (System.getProperty(Context.INITIAL_CONTEXT_FACTORY) == null) {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, javaURLContextFactory.class.getName());
System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
InitialContext ic = new InitialContext();
ic.createSubcontext("java:");
ic.createSubcontext("java:comp");
ic.createSubcontext("java:comp/env");
ic.createSubcontext("java:comp/env/jdbc");
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("memory:testDB");
ds.setCreateDatabase("create");
ic.bind("java:comp/env/jdbc/testDS", ds);
}
}
示例2: configs
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Parameterized.Parameters
public static Collection<Object[]> configs() {
EmbeddedDataSource derbyDs = new EmbeddedDataSource();
derbyDs.setDatabaseName("test");
derbyDs.setCreateDatabase("create");
JdbcDataSource h2Ds = new JdbcDataSource();
h2Ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
// Tests on postgres disabled
// PGPoolingDataSource postgresDs = new PGPoolingDataSource();
// postgresDs.setServerName("localhost");
// postgresDs.setDatabaseName("syndesis");
// postgresDs.setUser("postgres");
// postgresDs.setPassword("password");
return Arrays.asList(new Object[][]{
{derbyDs},
// {postgresDs},
{h2Ds}
});
}
示例3: createDataSource
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
public static DataSource createDataSource(String homeDir) throws IOException {
// Setup the Derby datasource.
System.setProperty("derby.system.home", homeDir);
System.setProperty("derby.storage.fileSyncTransactionLog", "true");
System.setProperty("derby.storage.pageCacheSize", "100");
final EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("derbydb");
ds.setCreateDatabase("create");
return ds;
}
示例4: createPersistenceAdapter
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Override
protected PersistenceAdapter createPersistenceAdapter() throws IOException {
JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
EmbeddedDataSource dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName("derbyDb");
dataSource.setCreateDatabase("create");
jdbc.setDataSource(dataSource);
jdbc.setCleanupPeriod(1000); // set up small cleanup period
return jdbc;
}
示例5: initDB
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
private void initDB() {
try {
logger.debug("Initializing DB...");
Database db = new DatabaseIO().read(new InputStreamReader(JvmMonitorLoader.class.getResourceAsStream("/dbSchema.xml"), "UTF-8"));
Platform platform = PlatformFactory.createNewPlatformInstance(DerbyPlatform.DATABASENAME);
EmbeddedDataSource dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName(databasePath + DB_NAME);
dataSource.setCreateDatabase("create");
platform.setDataSource(dataSource);
if (platform.readModelFromDatabase(DB_NAME).getTableCount() == 0) { //TODO is that needed?
platform.createTables(db, false, false);
} else {
platform.alterTables(db, false);
}
} catch (DdlUtilsException | UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
示例6: before
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@BeforeClass
public void before() {
storage = new StorageServiceImpl();
EmbeddedDataSource dataSource = new EmbeddedConnectionPoolDataSource();
dataSource.setDatabaseName(System.getProperty("java.io.tmpdir") +
File.separator + "chii2" +
File.separator + "mqtt" +
File.separator + "server");
dataSource.setCreateDatabase("create");
storage.setDataSource(dataSource);
storage.start();
storage.clearTable("MESSAGE_ID");
storage.clearTable("RETAIN");
storage.clearTable("INFLIGHT");
storage.clearTable("QOS2");
storage.clearTable("SUBSCRIPTION");
}
示例7: createEntityManagerFactory
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
private EntityManagerFactory createEntityManagerFactory() {
try {
Properties connectionProperties = new Properties();
connectionProperties.load(ClassLoader.getSystemResourceAsStream("at/arz/ngs/connection.properties"));
EmbeddedDataSource dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName("memory:ngs-service-db");
dataSource.setCreateDatabase("create");
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(JPA_UNIT_NAME,
connectionProperties);
return entityManagerFactory;
}
catch (IOException e) {
throw new RuntimeException("could not load create entity manager factory", e);
}
}
示例8: setUp
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName(dbName);
dataSource.setCreateDatabase("create");
conn = dataSource.getConnection();
TestDb.dropTables(conn);
TestDb.buildCoffeeTable(conn);
}
示例9: provideDataSource
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Singleton
@Provides
DataSource provideDataSource() {
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("Network");
ds.setCreateDatabase("create");
return ds;
}
示例10: create
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
public DataSource create() {
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName(dbname);
if (create)
ds.setCreateDatabase("create");
return ds;
}
示例11: provideDataSource
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Singleton
@Provides
DataSource provideDataSource() {
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("Auth");
ds.setCreateDatabase("create");
return ds;
}
示例12: initDataSource
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
private static void initDataSource(String dbname, String user,
String password) {
ds = new EmbeddedDataSource();
ds.setDatabaseName(dbname);
ds.setUser(user);
ds.setPassword(password);
ds.setCreateDatabase("create");
}
示例13: setup
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
protected void setup(final EmbeddedDataSource inSource,
final Properties inProperties) {
if (inProperties == null) {
return;
}
if (inProperties.containsKey(DataSourceFactory.JDBC_DATABASE_NAME)) {
inSource.setDatabaseName(inProperties
.getProperty(DataSourceFactory.JDBC_DATABASE_NAME));
inSource.setCreateDatabase("create");
}
if (inProperties.containsKey(DataSourceFactory.JDBC_DATASOURCE_NAME)) {
// not supported?
}
if (inProperties.containsKey(DataSourceFactory.JDBC_DESCRIPTION)) {
// not supported?
}
if (inProperties.containsKey(DataSourceFactory.JDBC_NETWORK_PROTOCOL)) {
// not supported?
}
if (inProperties.containsKey(DataSourceFactory.JDBC_PASSWORD)) {
inSource.setPassword(inProperties
.getProperty(DataSourceFactory.JDBC_PASSWORD));
}
if (inProperties.containsKey(DataSourceFactory.JDBC_USER)) {
inSource.setUser(inProperties
.getProperty(DataSourceFactory.JDBC_USER));
}
}
示例14: setupDatasource
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
protected void setupDatasource() throws Exception {
destroyDatasource();
InitialContext ic = new InitialContext();
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("memory:testDB");
ds.setCreateDatabase("create");
ic.bind("java:comp/env/jdbc/testDS", ds);
}
示例15: createConnection
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
public static Connection createConnection() throws SQLException {
MjdbcUtils.loadDriver("org.apache.derby.jdbc.EmbeddedDataSource");
EmbeddedDataSource ds = new org.apache.derby.jdbc.EmbeddedDataSource();
ds.setCreateDatabase("create");
ds.setDatabaseName("memory:testDb");
Connection conn = ds.getConnection();
return conn;
}