Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.SimpleDriverDataSource


   * 构造数据源,仅构造一次.
   * 连接参数从配置文件中读取,可指向本地的开发环境,也可以指向远程的测试服务器。
   */
  protected static void buildDataSourceOnce() throws ClassNotFoundException {
    if (dataSource == null) {
      dataSource = new SimpleDriverDataSource();
      dataSource.setDriverClass((Class<? extends Driver>) Class.forName(propertiesLoader
          .getProperty("jdbc.driver")));
      dataSource.setUrl(propertiesLoader.getProperty("jdbc.url"));
      dataSource.setUsername(propertiesLoader.getProperty("jdbc.username"));
      dataSource.setPassword(propertiesLoader.getProperty("jdbc.password"));
View Full Code Here


  /**
   * 构造数据源,仅构造一次.
   */
  protected static void buildDataSourceOnce() throws ClassNotFoundException {
    if (dataSource == null) {
      dataSource = new SimpleDriverDataSource();
      dataSource.setDriverClass((Class<? extends Driver>) Class.forName(propertiesLoader
          .getProperty("jdbc.driver")));
      dataSource.setUrl(propertiesLoader.getProperty("jdbc.url"));
      dataSource.setUsername(propertiesLoader.getProperty("jdbc.username"));
      dataSource.setPassword(propertiesLoader.getProperty("jdbc.password"));
View Full Code Here

          .build();
    } else if ("fs".equalsIgnoreCase(database)) {
      String tmpdir = System.getProperty("java.io.tmpdir");
      String dbname = env.getProperty("application.name", "testdb");
      String jdbcUrl = "jdbc:h2:" + tmpdir + File.separator + dbname;
      SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
      @SuppressWarnings("unchecked")
      Class<? extends Driver> driverClass =
          (Class<? extends Driver>) ClassUtils.forName(H2_DRIVER,
              DataSources.class.getClassLoader());
      dataSource.setDriverClass(driverClass);
      dataSource.setUrl(jdbcUrl);
      dataSource.setUsername("sa");
      dataSource.setPassword("");
      logger.info("Creating embedded database: '{}'", jdbcUrl);
      return dataSource;
    } else {
      return null;
    }
View Full Code Here

  public void fs() throws Exception {
    Environment env = createMock(Environment.class);
    expect(env.getRequiredProperty("db")).andReturn("fs");
    expect(env.getProperty("application.name", "testdb")).andReturn("fsdb");

    SimpleDriverDataSource dataSource =
        PowerMock.createMockAndExpectNew(SimpleDriverDataSource.class);
    dataSource.setDriverClass((Class<? extends Driver>) Class
        .forName("org.h2.Driver"));
    expectLastCall();
    String databaseUrl =
        String.format("jdbc:h2:%s" + File.separator + "fsdb",
            System.getProperty("java.io.tmpdir"));
    dataSource.setUrl(databaseUrl);
    expectLastCall();
    dataSource.setUsername("sa");
    expectLastCall();
    dataSource.setPassword("");
    expectLastCall();

    PowerMock.replay(SimpleDriverDataSource.class);
    replay(env, dataSource);
View Full Code Here

    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    String flashdbDataSourceUrl = props.getProperty("flashdbDataSourceUrl");
   
    SimpleDriverDataSource flashdbDataSource = beanFactory.getBean("flashdbDataSource", SimpleDriverDataSource.class);
    flashdbDataSource.setUrl("jdbc:FlashDB:"+ flashdbDataSourceUrl);

    this.flashDatabase = Utils.dataSource2flashdb(flashdbDataSource);
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.datasource.SimpleDriverDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.