Java Code Examples for org.apache.derby.jdbc.EmbeddedDriver

The following examples show how to use org.apache.derby.jdbc.EmbeddedDriver. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
	properties.setDriverClass(EmbeddedDriver.class);
	properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true"));
	properties.setUsername("sa");
	properties.setPassword("");
}
 
Example 2
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex);
		}
	}
}
 
Example 3
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
	properties.setDriverClass(EmbeddedDriver.class);
	properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true"));
	properties.setUsername("sa");
	properties.setPassword("");
}
 
Example 4
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex);
		}
	}
}
 
Example 5
Source Project: beeju   Source File: BeejuCore.java    License: Apache License 2.0 5 votes vote down vote up
public BeejuCore(String databaseName, Map<String, String> configuration) {
  checkNotNull(databaseName, "databaseName is required");
  this.databaseName = databaseName;

  if (configuration != null && !configuration.isEmpty()) {
    for (Map.Entry<String, String> entry : configuration.entrySet()) {
      conf.set(entry.getKey(), entry.getValue());
    }
  }

  driverClassName = EmbeddedDriver.class.getName();
  conf.setBoolean("hcatalog.hive.client.cache.disabled", true);
  connectionURL = "jdbc:derby:memory:" + UUID.randomUUID() + ";create=true";
  conf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY, connectionURL);
  conf.setVar(HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER, driverClassName);
  conf.setVar(HiveConf.ConfVars.METASTORE_CONNECTION_USER_NAME, METASTORE_DB_USER);
  conf.setVar(HiveConf.ConfVars.METASTOREPWD, METASTORE_DB_PASSWORD);
  conf.setBoolVar(HiveConf.ConfVars.HMSHANDLERFORCERELOADCONF, true);
  // Hive 2.x compatibility
  conf.setBoolean("datanucleus.schema.autoCreateAll", true);
  conf.setBoolean("hive.metastore.schema.verification", false);
  // override default port as some of our test environments claim it is in use.
  conf.setInt("hive.server2.webui.port", 0); // ConfVars.HIVE_SERVER2_WEBUI_PORT
  try {
    // overriding default derby log path to go to tmp
    String derbyLog = File.createTempFile("derby", ".log").getCanonicalPath();
    System.setProperty("derby.stream.error.file", derbyLog);

    //Creating temporary folder
    createWarehousePath();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 6
Source Project: beeju   Source File: BeejuCoreTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void checkConfig() {
  assertThat(defaultCore.driverClassName(), is(EmbeddedDriver.class.getName()));
  assertThat(defaultCore.conf().getVar(HiveConf.ConfVars.METASTORECONNECTURLKEY), is(defaultCore.connectionURL()));
  assertThat(defaultCore.conf().getVar(HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER),
      is(defaultCore.driverClassName()));
  assertThat(defaultCore.conf().getVar(HiveConf.ConfVars.METASTORE_CONNECTION_USER_NAME), is("db_user"));
  assertThat(defaultCore.conf().getVar(HiveConf.ConfVars.METASTOREPWD), is("db_password"));
  assertThat(defaultCore.conf().getBoolVar(HiveConf.ConfVars.HMSHANDLERFORCERELOADCONF), is(true));
  assertThat(defaultCore.conf().get("datanucleus.schema.autoCreateAll"), is("true"));
  assertThat(defaultCore.conf().get("hive.metastore.schema.verification"), is("false"));
  assertThat(defaultCore.conf().get("hive.server2.webui.port"), is("0"));
  assertThat(defaultCore.conf().get("hcatalog.hive.client.cache.disabled"), is("true"));
}
 
Example 7
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
	properties.setDriverClass(EmbeddedDriver.class);
	properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true"));
	properties.setUsername("sa");
	properties.setPassword("");
}
 
Example 8
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex);
		}
	}
}
 
Example 9
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
	properties.setDriverClass(EmbeddedDriver.class);
	properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true"));
	properties.setUsername("sa");
	properties.setPassword("");
}
 
Example 10
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex);
		}
	}
}
 
Example 11
Source Project: james-project   Source File: JDBCMailRepositoryTest.java    License: Apache License 2.0 5 votes vote down vote up
private BasicDataSource getDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(EmbeddedDriver.class.getName());
    ds.setUrl("jdbc:derby:target/testdb;create=true");
    ds.setUsername("james");
    ds.setPassword("james");
    return ds;
}
 
Example 12
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
	properties.setDriverClass(EmbeddedDriver.class);
	properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true"));
	properties.setUsername("sa");
	properties.setPassword("");
}
 
Example 13
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shutdown in-memory Derby database", ex);
		}
	}
}
 
Example 14
Source Project: tomee   Source File: EarWarResourcesXmlTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> app() {
    return ShrinkWrap.create(EnterpriseArchive.class, "EarWarResourcesXmlTest.ear")
            .addAsModule(ShrinkWrap.create(WebArchive.class, "web.war")
                    .addClass(EarWarResourcesXmlTest.class)
                    .addAsLibraries(jarLocation(EmbeddedDriver.class))
                    .addAsWebInfResource(new StringAsset("<resources>\n" +
                            "  <Resource id=\"derby\" type=\"DataSource\">\n" +
                            "    JdbcDriver = org.apache.derby.jdbc.EmbeddedDriver\n" +
                            "    JdbcUrl = jdbc:derby:memory:EarWarResourcesXmlTest;create=true\n" +
                            "    UserName = SA\n" +
                            "    Lazy = true\n" +
                            "  </Resource>\n" +
                            "</resources>"), "resources.xml"));
}
 
Example 15
Source Project: incubator-batchee   Source File: ContainerLifecycle.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(final ITestContext iTestContext) {
    final String loggerName = "test-lifecycle";

    container = EJBContainer.createEJBContainer(new PropertiesBuilder()
        .p("openejb.jul.forceReload", Boolean.TRUE.toString())
        .p("openejb.log.color", Boolean.toString(!System.getProperty("os.name").toLowerCase().contains("win")))
        .p(loggerName + ".level", "INFO")
        .p("openejb.jdbc.log", Boolean.FALSE.toString()) // with jdbc set it to TRUE to get sql queries

        .p("jdbc/orderDB", "new://Resource?type=DataSource")
        .p("jdbc/orderDB.JdbcDriver", EmbeddedDriver.class.getName())
        .p("jdbc/orderDB.JdbcUrl", "jdbc:derby:memory:orderDB" + ";create=true")
        .p("jdbc/orderDB.UserName", "app")
        .p("jdbc/orderDB.Password", "app")
        .p("jdbc/orderDB.JtaManaged", Boolean.TRUE.toString())

        .p("jdbc/batchee", "new://Resource?type=DataSource")
        .p("jdbc/batchee.JdbcDriver", EmbeddedDriver.class.getName())
        .p("jdbc/batchee.JdbcUrl", "jdbc:derby:memory:batchee" + ";create=true")
        .p("jdbc/batchee.UserName", "app")
        .p("jdbc/batchee.Password", "app")
        .p("jdbc/batchee.JtaManaged", Boolean.FALSE.toString())
        .build());

    logger = Logger.getLogger(loggerName);
}