當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSourceFactory.setUser方法代碼示例

本文整理匯總了Java中io.dropwizard.db.DataSourceFactory.setUser方法的典型用法代碼示例。如果您正苦於以下問題:Java DataSourceFactory.setUser方法的具體用法?Java DataSourceFactory.setUser怎麽用?Java DataSourceFactory.setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.dropwizard.db.DataSourceFactory的用法示例。


在下文中一共展示了DataSourceFactory.setUser方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setup

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setup() throws Exception
{
    DBIFactory factory = new DBIFactory();
    Environment environment = new Environment("test", new ObjectMapper(), null, new MetricRegistry(), ClassLoader.getSystemClassLoader());
    DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:hsqldb:mem:soa-jdbi;shutdown=true");
    dataSourceFactory.setDriverClass("org.hsqldb.jdbc.JDBCDriver");
    dataSourceFactory.setLogValidationErrors(true);
    dataSourceFactory.setUser("SA");
    dataSourceFactory.setValidationQuery("SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES");
    DBI jdbi = factory.build(environment, dataSourceFactory, "test");
    dynamicAttributes = new JdbiDynamicAttributes(jdbi, Collections.singletonList("test"));

    dynamicAttributes.getDao().createTable();
    dynamicAttributes.start();
}
 
開發者ID:soabase,項目名稱:soabase,代碼行數:18,代碼來源:TestJdbiDynamicAttributes.java

示例2: setUp

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    environment = new Environment("test", new ObjectMapper(), Validators.newValidator(),
            metricRegistry, ClassLoader.getSystemClassLoader());

    DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:h2:mem:jdbi3-test");
    dataSourceFactory.setUser("sa");
    dataSourceFactory.setDriverClass("org.h2.Driver");
    dataSourceFactory.asSingleConnectionPool();

    dbi = new JdbiFactory(new TimedAnnotationNameStrategy()).build(environment, dataSourceFactory, "h2");
    dbi.useTransaction(h -> {
        h.createScript(Resources.toString(Resources.getResource("schema.sql"), Charsets.UTF_8)).execute();
        h.createScript(Resources.toString(Resources.getResource("data.sql"), Charsets.UTF_8)).execute();
    });
    dao = dbi.onDemand(GameDao.class);
    for (LifeCycle lc : environment.lifecycle().getManagedObjects()) {
        lc.start();
    }
}
 
開發者ID:arteam,項目名稱:dropwizard-jdbi3,代碼行數:22,代碼來源:JdbiTest.java

示例3: setUp

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() {
  //create a valid config
  DataSourceFactory dataSourceFactory = new DataSourceFactory();
  dataSourceFactory.setDriverClass("org.postgresql.Driver");
  dataSourceFactory.setUrl("jdbc:postgresql://db.example.com/db-prod");
  dataSourceFactory.setUser("user");
  CassandraFactory cassandraFactory = new CassandraFactory();
  cassandraFactory.setContactPoints(new String[]{"127.0.0.1"});
  config.setCassandraFactory(cassandraFactory);
  config.setPostgresDataSourceFactory(dataSourceFactory);
  config.setHangingRepairTimeoutMins(1);
  config.setRepairParallelism(RepairParallelism.DATACENTER_AWARE);
  config.setRepairRunThreadCount(1);
  config.setSegmentCount(1);
  config.setScheduleDaysBetween(7);
  config.setStorageType("foo");
  config.setIncrementalRepair(false);
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:20,代碼來源:ReaperApplicationConfigurationTest.java

示例4: initializeConnection

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
private void initializeConnection() throws SQLException {
    if (connection == null) {
        DataSourceFactory factory = new DataSourceFactory();

        factory.setDriverClass(getDriverClass());
        factory.setUrl(String.format("%s//%s/%s", getJDBCUrlPrefix(), dbUrl, dbName));
        factory.setProperties(getJDBCProperties());

        if (dbUser != null) {
            factory.setUser(this.dbUser);
        }
        if (dbPassword != null) {
            factory.setPassword(dbPassword);
        }

        source = factory.build(MacroBase.metrics, dbName);
        this.connection = source.getConnection();
    }
}
 
開發者ID:stanford-futuredata,項目名稱:macrobase,代碼行數:20,代碼來源:SQLIngester.java

示例5: uses_configured_dropwizard_values

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Test
public void uses_configured_dropwizard_values() {
  final CamundaConfiguration configuration = new CamundaConfiguration();
  final DataSourceFactory database = configuration.getCamunda().getDatabase();
  database.setDriverClass(DRIVER);
  database.setUser(USER);
  database.setPassword(PASSWORD);
  database.setUrl(URL);

  final ProcessEngineConfiguration processEngineConfiguration = configuration.buildProcessEngineConfiguration();

  assertThat(processEngineConfiguration.getJdbcDriver()).isEqualTo(DRIVER);
  assertThat(processEngineConfiguration.getJdbcUsername()).isEqualTo(USER);
  assertThat(processEngineConfiguration.getJdbcPassword()).isEqualTo(PASSWORD);
  assertThat(processEngineConfiguration.getJdbcUrl()).isEqualTo(URL);
}
 
開發者ID:camunda,項目名稱:camunda-bpm-dropwizard,代碼行數:17,代碼來源:CamundaConfigurationTest.java

示例6: getDataSourceFactory

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
private DataSourceFactory getDataSourceFactory() {
  DataSourceFactory dataSourceFactory = new DataSourceFactory();
  dataSourceFactory.setDriverClass("org.h2.Driver");
  dataSourceFactory.setUrl("jdbc:h2:mem:singularity;DB_CLOSE_DELAY=-1");
  dataSourceFactory.setUser("user");
  dataSourceFactory.setPassword("password");

  return dataSourceFactory;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:10,代碼來源:SingularityTestModule.java

示例7: setUp

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    final Environment environment = mock(Environment.class);
    when(environment.lifecycle()).thenReturn(mock(LifecycleEnvironment.class));
    when(environment.metrics()).thenReturn(new MetricRegistry());

    when(this.bundle.getSessionHolders()).thenReturn(this.sessionHolders);

    final DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:hsqldb:mem:unit-of-work-" + UUID.randomUUID().toString());
    dataSourceFactory.setUser("sa");
    dataSourceFactory.setDriverClass("org.hsqldb.jdbcDriver");
    dataSourceFactory.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
    dataSourceFactory.setProperties(ImmutableMap.of("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"));
    dataSourceFactory.setMinSize(1);

    this.sessionFactory = new SessionFactoryFactory()
            .build(this.bundle, environment, dataSourceFactory, ImmutableList.<Class<?>>of(), RemoteCredentialHibernateBundle.DEFAULT_NAME);
    when(this.bundle.getSessionFactory()).thenReturn(this.sessionFactory);
    final Session session = this.sessionFactory.openSession();
    try {
        session.createSQLQuery("create table user_sessions (token varchar(64) primary key, username varchar(16))")
                .executeUpdate();
        session.createSQLQuery("insert into user_sessions values ('67ab89d', 'jeff_28')")
                .executeUpdate();
    } finally {
        session.close();
    }
}
 
開發者ID:mtakaki,項目名稱:CredentialStorageService-dw-hibernate,代碼行數:30,代碼來源:UnitOfWorkAwareProxyFactoryTest.java

示例8: getDataSourceFactory

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
private DataSourceFactory getDataSourceFactory() {
    DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setDriverClass("org.postgresql.Driver");
    dataSourceFactory.setUrl("jdbc:postgresql://localhost:5432/ft_openregister_java_multi");
    dataSourceFactory.setUser("postgres");
    dataSourceFactory.setPassword("");
    return dataSourceFactory;
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:9,代碼來源:PostgresRegisterTransactionalFunctionalTest.java

示例9: setUp

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    when(bundle.name()).thenReturn(getClass().getSimpleName() + "-bundle");
    when(environment.metrics()).thenReturn(metricRegistry);
    when(environment.lifecycle()).thenReturn(lifecycleEnvironment);

    config = new DataSourceFactory();
    config.setUrl("jdbc:hsqldb:mem:DbTest-" + System.currentTimeMillis());
    config.setUser("sa");
    config.setDriverClass("org.hsqldb.jdbcDriver");
    config.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
}
 
開發者ID:scottescue,項目名稱:dropwizard-entitymanager,代碼行數:13,代碼來源:EntityManagerFactoryFactoryTest.java

示例10: setUp

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
    final EntityManagerBundle<?> bundle = mock(EntityManagerBundle.class);
    final Environment environment = mock(Environment.class);
    when(bundle.name()).thenReturn("test-bundle");
    when(environment.lifecycle()).thenReturn(mock(LifecycleEnvironment.class));
    when(environment.metrics()).thenReturn(new MetricRegistry());

    final DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:hsqldb:mem:unit-of-work-" + UUID.randomUUID().toString());
    dataSourceFactory.setUser("sa");
    dataSourceFactory.setDriverClass("org.hsqldb.jdbcDriver");
    dataSourceFactory.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
    dataSourceFactory.setProperties(ImmutableMap.of("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"));
    dataSourceFactory.setInitialSize(1);
    dataSourceFactory.setMinSize(1);

    entityManagerFactory = new EntityManagerFactoryFactory()
            .build(bundle, environment, dataSourceFactory, ImmutableList.<Class<?>>of());

    final EntityManager entityManager = entityManagerFactory.createEntityManager();
    try {
        EntityTransaction entityTransaction = entityManager.getTransaction();
        entityTransaction.begin();

        entityManager.createNativeQuery("create table user_sessions (token varchar(64) primary key, username varchar(16))")
                .executeUpdate();
        entityManager.createNativeQuery("insert into user_sessions values ('67ab89d', 'jeff_28')")
                .executeUpdate();

        entityTransaction.commit();
    } finally {
        entityManager.close();
    }

    final EntityManagerContext entityManagerContext = new EntityManagerContext(entityManagerFactory);
    sharedEntityManager = new SharedEntityManagerFactory().build(entityManagerContext);
}
 
開發者ID:scottescue,項目名稱:dropwizard-entitymanager,代碼行數:39,代碼來源:UnitOfWorkAwareProxyFactoryTest.java

示例11: clone

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
public static DataSourceFactory clone(DataSourceFactory dbConfig) {
    DataSourceFactory newConfig = new DataSourceFactory();
    newConfig.setUser(dbConfig.getUser());
    newConfig.setPassword(dbConfig.getPassword());
    newConfig.setUrl(dbConfig.getUrl());
    newConfig.setDriverClass(dbConfig.getDriverClass());
    newConfig.setMaxSize(dbConfig.getMaxSize());
    newConfig.setMinSize(dbConfig.getMinSize());
    newConfig.setInitialSize(dbConfig.getInitialSize());

    return newConfig;
}
 
開發者ID:Lugribossk,項目名稱:dropwizard-experiment,代碼行數:13,代碼來源:EbeanConfigUtils.java

示例12: configure

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Override
protected Application configure() {
    this.forceSet(TestProperties.CONTAINER_PORT, "0");

    final MetricRegistry metricRegistry = new MetricRegistry();
    final SessionFactoryFactory factory = new SessionFactoryFactory();
    final DataSourceFactory dbConfig = new DataSourceFactory();
    this.bundle = mock(RemoteCredentialHibernateBundle.class);

    final SessionHolders sessionHolders = mock(SessionHolders.class);
    when(this.bundle.getSessionHolders()).thenReturn(sessionHolders);

    final Environment environment = mock(Environment.class);
    final LifecycleEnvironment lifecycleEnvironment = mock(LifecycleEnvironment.class);
    when(environment.lifecycle()).thenReturn(lifecycleEnvironment);
    when(environment.metrics()).thenReturn(metricRegistry);

    dbConfig.setUrl("jdbc:hsqldb:mem:DbTest-" + System.nanoTime()
            + "?hsqldb.translate_dti_types=false");
    dbConfig.setUser("sa");
    dbConfig.setDriverClass("org.hsqldb.jdbcDriver");
    dbConfig.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");

    this.sessionFactory = factory.build(this.bundle,
            environment,
            dbConfig,
            ImmutableList.<Class<?>> of(Person.class),
            RemoteCredentialHibernateBundle.DEFAULT_NAME);
    when(this.bundle.getSessionFactory()).thenReturn(this.sessionFactory);
    when(this.bundle.getCurrentThreadSessionFactory()).thenReturn(this.sessionFactory);

    final Session session = this.sessionFactory.openSession();
    try {
        session.createSQLQuery("DROP TABLE people IF EXISTS").executeUpdate();
        session.createSQLQuery(
                "CREATE TABLE people (name varchar(100) primary key, email varchar(16), birthday timestamp with time zone)")
                .executeUpdate();
        session.createSQLQuery(
                "INSERT INTO people VALUES ('Coda', '[email protected]', '1979-01-02 00:22:00+0:00')")
                .executeUpdate();
    } finally {
        session.close();
    }

    final DropwizardResourceConfig config = DropwizardResourceConfig
            .forTesting(new MetricRegistry());
    config.register(new UnitOfWorkApplicationListener("hr-db", this.bundle));
    config.register(new PersonResource(new PersonDAO(this.bundle)));
    config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
            Validators.newValidator()));
    config.register(new DataExceptionMapper());

    return config;
}
 
開發者ID:mtakaki,項目名稱:CredentialStorageService-dw-hibernate,代碼行數:55,代碼來源:JerseyIntegrationTest.java

示例13: configure

import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Override
protected Application configure() {
    final MetricRegistry metricRegistry = new MetricRegistry();
    final DataSourceFactory dbConfig = new DataSourceFactory();
    final Environment environment = mock(Environment.class);
    final LifecycleEnvironment lifecycleEnvironment = mock(LifecycleEnvironment.class);
    when(environment.lifecycle()).thenReturn(lifecycleEnvironment);
    when(environment.metrics()).thenReturn(metricRegistry);

    String url = "jdbc:hsqldb:mem:dwtest" + System.nanoTime();

    Map<String, String> props = new HashMap<String, String>();
    props.put("username", "sa");
    props.put("password", "");
    props.put("url", url);

    try {
        HSQLDBInit.initPublic(props);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    dbConfig.setUrl(props.get("url"));
    dbConfig.setUser(props.get("user"));
    dbConfig.setDriverClass("org.hsqldb.jdbcDriver");
    dbConfig.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");

    final DropwizardResourceConfig config = DropwizardResourceConfig.forTesting(new MetricRegistry());

    DataSource dataSource = dbConfig.build(metricRegistry, "jooq");
    config.register(JooqTransactionalApplicationListener.class);

    Configuration configuration = new DefaultConfiguration().set(SQLDialect.HSQLDB);
    configuration.set(new DataSourceConnectionProvider(dataSource));

    config.register(new ConfigurationFactoryProvider.Binder(configuration, dataSource,
            new TestTenantConnectionProvider(dbConfig, metricRegistry, url)));
    config.register(ExampleResource.class);
    config.register(new JacksonMessageBodyProvider(Jackson.newObjectMapper(),
            Validation.buildDefaultValidatorFactory().getValidator()));
    return config;
}
 
開發者ID:tbugrara,項目名稱:dropwizard-jooq,代碼行數:43,代碼來源:ExampleResourceTest.java


注:本文中的io.dropwizard.db.DataSourceFactory.setUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。