Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.DriverManagerDataSource


    @Before
    public void setUp() throws Exception {
        Properties connectionProperties = new Properties();
        connectionProperties.put("autoCommit", Boolean.TRUE);
       
        DriverManagerDataSource dataSource = new SingleConnectionDataSource(url, user, password, true);
        dataSource.setDriverClassName(driverClass);
        dataSource.setConnectionProperties(connectionProperties);
        ds = dataSource;

        JdbcTemplate jdbc = new JdbcTemplate(ds);
        jdbc.execute("create table customer (id varchar(15) PRIMARY KEY, name varchar(10))");
        jdbc.execute("insert into customer values('cust1','jstrachan')");
View Full Code Here


        };
    }

    @Before
    public void setUp() throws Exception {
        DriverManagerDataSource dataSource = new DriverManagerDataSource(url, user, password);
        dataSource.setDriverClassName(driverClass);
        ds = dataSource;

        JdbcTemplate jdbc = new JdbcTemplate(ds);
        // START SNIPPET: setup
        jdbc.execute("create table customer (id varchar(15), name varchar(10))");
View Full Code Here

        return new DataSourceTransactionManager(dataSource());
    }

    @org.springframework.context.annotation.Bean
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource(
                "jdbc:h2:mem:",
                "sa",
                "");
        dataSource.setDriverClassName(Driver.class.getName());
        return dataSource;
    }
View Full Code Here

      throw new DBDatasourceServiceException( e );
    }
  }

  public static DataSource convert( IDatabaseConnection databaseConnection ) throws DBDatasourceServiceException {
    DriverManagerDataSource basicDatasource = new DriverManagerDataSource(); // From Spring
    IDatabaseDialectService databaseDialectService =
        PentahoSystem.get( IDatabaseDialectService.class, PentahoSessionHolder.getSession() );
    IDatabaseDialect dialect = databaseDialectService.getDialect( databaseConnection );
    if ( databaseConnection.getDatabaseType() == null && dialect == null ) {
      // We do not have enough information to create a DataSource. Throwing exception
      throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
          "PooledDatasourceHelper.ERROR_0001_DATASOURCE_CREATE_ERROR_NO_DIALECT", databaseConnection.getName() ) );
    }

    if ( databaseConnection.getDatabaseType().getShortName().equals( "GENERIC" ) ) { //$NON-NLS-1$
      String driverClassName =
          databaseConnection.getAttributes().get( GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS );
      if ( !StringUtils.isEmpty( driverClassName ) ) {
        basicDatasource.setDriverClassName( driverClassName );
      } else {
        // We do not have enough information to create a DataSource. Throwing exception
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0002_DATASOURCE_CREATE_ERROR_NO_CLASSNAME", databaseConnection.getName() ) );
      }

    } else {
      if ( !StringUtils.isEmpty( dialect.getNativeDriver() ) ) {
        basicDatasource.setDriverClassName( dialect.getNativeDriver() );
      } else {
        // We do not have enough information to create a DataSource. Throwing exception
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0003_DATASOURCE_CREATE_ERROR_NO_DRIVER", databaseConnection.getName() ) );
      }

    }
    try {
      basicDatasource.setUrl( dialect.getURLWithExtraOptions( databaseConnection ) );
    } catch ( DatabaseDialectException e ) {
      basicDatasource.setUrl( null );
    }
    basicDatasource.setUsername( databaseConnection.getUsername() );
    basicDatasource.setPassword( databaseConnection.getPassword() );

    return basicDatasource;
  }
View Full Code Here

    jpaListener.exceptionThrown(context, new FlowExecutionException("foo", "bar", "test"));
    assertSessionNotBound();
  }

  private DataSource getDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl("jdbc:hsqldb:mem:jpa");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
  }
View Full Code Here

    flowSession.setState(endState);
    return flowSession;
  }

  private DataSource createDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl("jdbc:hsqldb:mem:hspcl");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
  }
View Full Code Here

  protected abstract void assertSessionBound();

  /* private helper methods */

  private void initDataSource() {
    DriverManagerDataSource dmds = new DriverManagerDataSource();
    dmds.setDriverClassName("org.hsqldb.jdbcDriver");
    dmds.setUrl("jdbc:hsqldb:mem:jpa");
    dmds.setUsername("sa");
    dmds.setPassword("");
    dataSource = dmds;
  }
View Full Code Here

    Hibernate.initialize(bean.getAddresses());
    assertTrue("addresses should be initialized", Hibernate.isInitialized(bean.getAddresses()));
  }

  private DataSource getDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl("jdbc:hsqldb:mem:hspcl");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
  }
View Full Code Here

      logger.debug("Loaded test data in " + testDataLocation);
    }
  }

  private DataSource createDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    // use the HsqlDB JDBC driver
    dataSource.setDriverClassName("org.h2.Driver");
    // have it create an in-memory database
    dataSource.setUrl("jdbc:h2:mem:" + testDatabaseName + ";DB_CLOSE_DELAY=-1");
    dataSource.setUsername("sa");
    dataSource.setPassword("sa");
    return dataSource;
  }
View Full Code Here

    static final String USERNAME = "root";
    static final String PASSWORD = "123456";

    @Bean(name = "jdbcDataSource")
    public DriverManagerDataSource getJdbcDataSource() {
        DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
        driverManagerDataSource.setDriverClassName(DRIVE_CLASS_NAME);
        driverManagerDataSource.setUrl(URL);
        driverManagerDataSource.setUsername(USERNAME);
        driverManagerDataSource.setPassword(PASSWORD);
        return driverManagerDataSource;
    }
View Full Code Here

TOP

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

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.