Example usage for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource

List of usage examples for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource.

Prototype

public SimpleDriverDataSource(Driver driver, String url) 

Source Link

Document

Create a new DriverManagerDataSource with the given standard Driver parameters.

Usage

From source file:com.googlecode.jeeunit.example.test.spring.SpringTestConfig.java

@Bean
public DataSource dataSource() {
    return new SimpleDriverDataSource(new org.apache.derby.jdbc.EmbeddedDriver(),
            "jdbc:derby:target/jeeunitDb;create=true");
}

From source file:org.trustedanalytics.servicebroker.hive.config.ServiceInstanceProvisioningConfig.java

@Bean
public JdbcOperations hiveOperations(Driver driver) throws IOException {
    String hiveUrl = hiveClient.getConnectionUrl();
    LOGGER.info("Creating jdbc template for url: " + hiveUrl);
    if (!hiveClient.isKerberosEnabled()) {
        return new JdbcTemplate(new SimpleDriverDataSource(driver, hiveUrl));
    }/*  ww w  .  j av a 2  s.co m*/
    return kerberizedHiveOperations(hiveUrl);
}

From source file:org.apache.ctakes.ytex.uima.DBCollectionReader.java

protected void initDB(String dbDriver, String dbURL) throws ResourceInitializationException {
    if (dbURL != null && dbURL.length() > 0) {
        try {/*from  w ww .j  a  va  2 s. co m*/

            if (dbDriver == null || dbDriver.length() == 0) {
                dbDriver = ApplicationContextHolder.getYtexProperties().getProperty("db.driver");
            }
            dataSource = new SimpleDriverDataSource((Driver) Class.forName(dbDriver).newInstance(), dbURL);
            txTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
        } catch (InstantiationException e) {
            throw new ResourceInitializationException(e);
        } catch (IllegalAccessException e) {
            throw new ResourceInitializationException(e);
        } catch (ClassNotFoundException e) {
            throw new ResourceInitializationException(e);
        }
    } else {
        txTemplate = (TransactionTemplate) ApplicationContextHolder.getApplicationContext()
                .getBean("txTemplate");
        dataSource = (DataSource) ApplicationContextHolder.getApplicationContext()
                .getBean("collectionReaderDataSource");
    }
    simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
    namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:org.teiid.spring.autoconfigure.TeiidAutoConfiguration.java

@Bean(name = "dataSource")
@Primary//www .ja  v a 2s . com
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource(TeiidServer server, VDBMetaData vdb) {
    EmbeddedDatabaseFactory edf = new EmbeddedDatabaseFactory();
    edf.setDatabaseConfigurer(new TeiidDatabaseConfigurer(server));
    edf.setDataSourceFactory(new DataSourceFactory() {
        @Override
        public DataSource getDataSource() {
            String url = context.getEnvironment().getProperty("spring.datasource.teiid.url");
            return new SimpleDriverDataSource(new TeiidSpringDriver(server.getDriver(), server, vdb), url);
        }

        @Override
        public ConnectionProperties getConnectionProperties() {
            return new ConnectionProperties() {
                @Override
                public void setDriverClass(Class<? extends Driver> driverClass) {
                }

                @Override
                public void setUrl(String url) {
                }

                @Override
                public void setUsername(String username) {
                }

                @Override
                public void setPassword(String password) {
                }
            };
        }
    });
    return edf.getDatabase();
}