use of org.apache.derby.jdbc.EmbeddedDataSource in project jetty.project by eclipse.
the class DataSourceLoginServiceTest method configureLoginService.
public static DataSourceLoginService configureLoginService() throws Exception {
DataSourceLoginService loginService = new DataSourceLoginService();
loginService.setUserTableName("users");
loginService.setUserTableKey("id");
loginService.setUserTableUserField("username");
loginService.setUserTablePasswordField("pwd");
loginService.setRoleTableName("roles");
loginService.setRoleTableKey("id");
loginService.setRoleTableRoleField("role");
loginService.setUserRoleTableName("user_roles");
loginService.setUserRoleTableRoleKey("role_id");
loginService.setUserRoleTableUserKey("user_id");
loginService.setJndiName("dstest");
loginService.setName(__realm);
if (_testServer != null)
loginService.setServer(_testServer.getServer());
//create a datasource
EmbeddedDataSource ds = new EmbeddedDataSource();
File db = new File(DatabaseLoginServiceTestServer.getDbRoot(), "loginservice");
ds.setDatabaseName(db.getAbsolutePath());
org.eclipse.jetty.plus.jndi.Resource binding = new org.eclipse.jetty.plus.jndi.Resource(null, "dstest", ds);
assertThat("Created binding for dstest", binding, notNullValue());
return loginService;
}
use of org.apache.derby.jdbc.EmbeddedDataSource in project torodb by torodb.
the class OfficialDerbyDriver method getConfiguredDataSource.
@Override
public DataSource getConfiguredDataSource(DerbyDbBackendConfiguration configuration, String poolName) {
DataSource dataSource;
if (configuration.embedded()) {
EmbeddedDataSource embeddedDataSource = new EmbeddedDataSource();
embeddedDataSource.setCreateDatabase("create");
if (configuration.inMemory()) {
embeddedDataSource.setDatabaseName("memory:" + configuration.getDbName());
} else {
embeddedDataSource.setDatabaseName(configuration.getDbName());
}
try (Connection connection = embeddedDataSource.getConnection()) {
LOGGER.debug("Derby test connection has been successfully created.");
} catch (SQLException ex) {
throw new SystemException(ex);
}
embeddedDataSource.setCreateDatabase(null);
dataSource = embeddedDataSource;
} else {
ClientDataSource clientDataSource = new ClientDataSource();
clientDataSource.setServerName(configuration.getDbHost());
clientDataSource.setPortNumber(configuration.getDbPort());
clientDataSource.setUser(configuration.getUsername());
clientDataSource.setPassword(configuration.getPassword());
if (configuration.inMemory()) {
clientDataSource.setDatabaseName("memory:" + configuration.getDbName());
} else {
clientDataSource.setDatabaseName(configuration.getDbName());
}
dataSource = clientDataSource;
}
if (LOGGER.isTraceEnabled()) {
try {
dataSource.setLogWriter(LOGGER_WRITER);
} catch (SQLException sqlException) {
throw new SystemException(sqlException);
}
}
//TODO
try (Connection conn = dataSource.getConnection();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT 1 FROM SYSIBM.SYSDUMMY1")) {
rs.next();
} catch (SQLException ex) {
throw new SystemException(ex);
}
return dataSource;
}
use of org.apache.derby.jdbc.EmbeddedDataSource in project aries by apache.
the class DerbyActivator method createDataSource.
public DataSource createDataSource(Properties props) {
EmbeddedDataSource embeddedDataSource = new EmbeddedDataSource();
embeddedDataSource.setDataSourceName(props.getProperty(JDBC_DATASOURCE_NAME));
embeddedDataSource.setDatabaseName(props.getProperty(JDBC_DATABASE_NAME));
embeddedDataSource.setUser(props.getProperty(JDBC_USER));
embeddedDataSource.setPassword(props.getProperty(JDBC_PASSWORD));
return embeddedDataSource;
}
Aggregations