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


Java EmbeddedDataSource类代码示例

本文整理汇总了Java中org.apache.derby.jdbc.EmbeddedDataSource的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedDataSource类的具体用法?Java EmbeddedDataSource怎么用?Java EmbeddedDataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EmbeddedDataSource类属于org.apache.derby.jdbc包,在下文中一共展示了EmbeddedDataSource类的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);

    }
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:20,代码来源:BaseTest.java

示例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}
        });
    }
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:24,代码来源:SqlFileStoreTest.java

示例3: testDerbyDataSource

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
@Test
public void testDerbyDataSource() throws SQLException {
    BQRuntime runtime = testFactory.app("-c", "classpath:HikariCPDerbyIT.yml")
            .autoLoadModules()
            .createRuntime();

    DataSource ds4 = runtime.getInstance(DataSourceFactory.class).forName("derby4");
    assertNotNull(ds4);
    assertTrue(ds4 instanceof HikariDataSource);

    HikariDataSource hikariDS = (HikariDataSource) ds4;

    assertEquals("org.apache.derby.jdbc.EmbeddedDataSource", hikariDS.getDataSourceClassName());

    HikariPool pool = (HikariPool) hikariDS.getHikariPoolMXBean();

    assertTrue(pool.getUnwrappedDataSource().getClass().isAssignableFrom(EmbeddedDataSource.class));

    try (Connection c = hikariDS.getConnection()) {
        assertEquals("jdbc:derby:target/derby4", c.getMetaData().getURL());
    }
}
 
开发者ID:bootique,项目名称:bootique-jdbc,代码行数:23,代码来源:HikariCPDerbyIT.java

示例4: 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;
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:13,代码来源:DataSourceServiceSupport.java

示例5: messageSent

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
@Override
protected void messageSent() throws Exception {
   verifyExpectedBroker(inflightMessageCount);
   if (++inflightMessageCount == failureCount) {
      LOG.info("STOPPING [email protected]!!!!");
      final EmbeddedDataSource ds = ((SyncCreateDataSource) getExistingDataSource()).getDelegate();
      ds.setShutdownDatabase("shutdown");
      LOG.info("DB [email protected]!!!!");

      Thread dbRestartThread = new Thread("db-re-start-thread") {
         @Override
         public void run() {
            delayTillRestartRequired();
            ds.setShutdownDatabase("false");
            LOG.info("DB RE[email protected]!!!!");
         }
      };
      dbRestartThread.start();
   }
   verifyExpectedBroker(inflightMessageCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:DbRestartJDBCQueueMasterSlaveTest.java

示例6: 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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:JDBCDurableSubscriptionTest.java

示例7: 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);
    }
}
 
开发者ID:Glamdring,项目名称:jvm-monitor,代码行数:19,代码来源:JvmMonitorLoader.java

示例8: 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");
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:18,代码来源:StorageServiceImplTest.java

示例9: 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);
	}
}
 
开发者ID:arz-ngs,项目名称:arz-ngs,代码行数:16,代码来源:AbstractJpaIT.java

示例10: 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);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:11,代码来源:JDBCRecordReaderTest.java

示例11: stopDerby

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
private void stopDerby() {
   LOG.info("STOPPING [email protected]!!!!");
   final EmbeddedDataSource ds = dataSource;
   try {
      ds.setShutdownDatabase("shutdown");
      ds.getConnection();
   } catch (Exception ignored) {
   }

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:JdbcXARecoveryBrokerTest.java

示例12: setUp

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
   setAutoFail(true);
   topic = false;
   verbose = true;
   // startup db
   sharedDs = (EmbeddedDataSource) DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory());

   broker = new BrokerService();

   DefaultIOExceptionHandler handler = new DefaultIOExceptionHandler();
   handler.setIgnoreSQLExceptions(false);
   handler.setStopStartConnectors(true);
   broker.setIoExceptionHandler(handler);
   broker.addConnector("tcp://localhost:0");
   broker.setUseJmx(false);
   broker.setPersistent(true);
   broker.setDeleteAllMessagesOnStartup(true);
   JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter();
   persistenceAdapter.setDataSource(sharedDs);
   persistenceAdapter.setUseLock(false);
   persistenceAdapter.setLockKeepAlivePeriod(500);
   persistenceAdapter.getLocker().setLockAcquireSleepInterval(500);
   broker.setPersistenceAdapter(persistenceAdapter);
   broker.start();
   super.setUp();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:DbRestartJDBCQueueTest.java

示例13: messageSent

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
@Override
protected void messageSent() throws Exception {
   if (++inflightMessageCount == failureCount) {
      LOG.info("STOPPING [email protected]!!!!");
      final EmbeddedDataSource ds = sharedDs;
      ds.setShutdownDatabase("shutdown");
      try {
         ds.getConnection();
      } catch (Exception ignored) {
      }
      LOG.info("DB [email protected]!!!!");

      Thread dbRestartThread = new Thread("db-re-start-thread") {
         @Override
         public void run() {
            LOG.info("Sleeping for 10 seconds before allowing db restart");
            try {
               restartDBLatch.await(10, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
               e.printStackTrace();
            }
            ds.setShutdownDatabase("false");
            LOG.info("DB [email protected]!!!!");
         }
      };
      dbRestartThread.start();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:29,代码来源:DbRestartJDBCQueueTest.java

示例14: testJdbcConfig

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
@Test
public void testJdbcConfig() throws Exception {
   File journalFile = new File(JOURNAL_ROOT + "testJDBCConfig/journal");
   recursiveDelete(journalFile);

   File derbyFile = new File(DERBY_ROOT + "testJDBCConfig/derbydb"); // Default
   recursiveDelete(derbyFile);

   BrokerService broker;
   broker = createBroker(new FileSystemResource(CONF_ROOT + "jdbc-example.xml"));
   try {
      assertEquals("Broker Config Error (brokerName)", "brokerJdbcConfigTest", broker.getBrokerName());

      PersistenceAdapter adapter = broker.getPersistenceAdapter();

      assertTrue("Should have created a jdbc persistence adapter", adapter instanceof JDBCPersistenceAdapter);
      assertEquals("JDBC Adapter Config Error (cleanupPeriod)", 60000, ((JDBCPersistenceAdapter) adapter).getCleanupPeriod());
      assertTrue("Should have created an EmbeddedDataSource", ((JDBCPersistenceAdapter) adapter).getDataSource() instanceof EmbeddedDataSource);
      assertTrue("Should have created a DefaultWireFormat", ((JDBCPersistenceAdapter) adapter).getWireFormat() instanceof ObjectStreamWireFormat);

      LOG.info("Success");
   } finally {
      if (broker != null) {
         broker.stop();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:JDBCConfigTest.java

示例15: createTablesOnInitialize

import org.apache.derby.jdbc.EmbeddedDataSource; //导入依赖的package包/类
private static boolean createTablesOnInitialize(DataSource dataSource) {
	// If the classes are not in the classpath a 'instanceof' would throw ClassNotFoundError
	if (StringUtils.equals(dataSource.getClass().getName(), "org.apache.derby.jdbc.EmbeddedDataSource")) {
		return "create".equals(((EmbeddedDataSource) dataSource).getCreateDatabase());
	} else if (StringUtils.equals(dataSource.getClass().getName(), "org.h2.jdbcx.JdbcDataSource")) {
		String url = ((JdbcDataSource) dataSource).getUrl();
		if (url.startsWith("jdbc:h2:mem")) {
			return true;
		}
		String databaseFile = url.substring("jdbc:h2:".length());
		return !new File(databaseFile).exists();
	}
	return false;
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:15,代码来源:SqlRepository.java


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