Spring Framework SimpleDriverDataSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework SimpleDriverDataSource class.

This code example shows how to use the following methods:setDriverClass, setUrl, setUsername
    return entityManagerFactoryBean.getObject(); 
  } 
   
  @Bean 
  public DataSource dataSource() {  
    SimpleDriverDataSource ds = new SimpleDriverDataSource(); 
    ds.setDriverClass(org.h2.Driver.class); 
     
    // Connection settings 
    ds.setUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"); 
    ds.setUsername("sa"); 
     
    return ds; 
  } 
 
  @Bean(name = "transactionManager") 
  public PlatformTransactionManager annotationDrivenTransactionManager() { 
    JpaTransactionManager transactionManager = new JpaTransactionManager(); 
    transactionManager.setEntityManagerFactory(entityManagerFactory()); 
    return transactionManager; 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDriverClass, setUrl, setUsername
 
  private final Logger log = LoggerFactory.getLogger(ActivitiEngineConfiguration.class); 
   
  @Bean 
  public DataSource dataSource() {  
    SimpleDriverDataSource ds = new SimpleDriverDataSource(); 
    ds.setDriverClass(org.h2.Driver.class); 
     
    // Connection settings 
    ds.setUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"); 
    ds.setUsername("sa"); 
     
    return ds; 
  } 
 
  @Bean(name = "transactionManager") 
  public PlatformTransactionManager annotationDrivenTransactionManager() { 
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(); 
    transactionManager.setDataSource(dataSource()); 
    return transactionManager; 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDriverClass, setUrl
	static JdbcTemplate template; 
 
	@BeforeClass 
	public static void setUp() { 
		dbFile = System.getProperty("java.io.tmpdir") + File.separator + "batch_sqlite_inc.db"; 
		dataSource = new SimpleDriverDataSource(); 
		dataSource.setDriverClass(org.sqlite.JDBC.class); 
		dataSource.setUrl("jdbc:sqlite:" + dbFile); 
		template = new JdbcTemplate(dataSource); 
		template.execute("create table max_value (id integer primary key autoincrement)"); 
	} 
 
	@AfterClass 
	public static void removeDbFile() { 
		File db = new File(dbFile); 
		if (db.exists()) { 
			db.delete(); 
		} 
		dataSource = null; 
		template = null; 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDriverClass, setPassword, setUrl, setUsername
    @Value("${cb.hbm2ddl.strategy:update}") 
    private String hbm2ddlStrategy; 
 
    @Bean 
    public DataSource dataSource() { 
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); 
        dataSource.setDriverClass(Driver.class); 
        dataSource.setUrl(String.format("jdbc:postgresql://%s:%s/%s", dbHost, dbPort, dbName)); 
        dataSource.setUsername(dbUser); 
        dataSource.setPassword(dbPassword); 
        return dataSource; 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager() throws Exception { 
        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(); 
        jpaTransactionManager.setEntityManagerFactory(entityManagerFactory()); 
        jpaTransactionManager.afterPropertiesSet(); 
        return jpaTransactionManager; 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDriverClass, setPassword, setUrl, setUsername
    @Value("${periscope.db.hbm2ddl.strategy:update}") 
    private String hbm2ddlStrategy; 
 
    @Bean 
    public DataSource dataSource() { 
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); 
        dataSource.setDriverClass(Driver.class); 
        dataSource.setUrl(String.format("jdbc:postgresql://%s:%s/%s", dbHost, dbPort, dbName)); 
        dataSource.setUsername(dbUser); 
        dataSource.setPassword(dbPassword); 
        return dataSource; 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager() throws Exception { 
        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(); 
        jpaTransactionManager.setEntityManagerFactory(entityManagerFactory()); 
        jpaTransactionManager.afterPropertiesSet(); 
        return jpaTransactionManager; 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setUrl
        assertEquals(TEST_URL, this.dataSourceUtils.getUrl(dataSource));
    } 
 
    @Test
    public void simpleDriverUrl() { 
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
        dataSource.setUrl(TEST_URL);
        assertEquals(TEST_URL, this.dataSourceUtils.getUrl(dataSource));
    } 
 
    @Test
    public void indeterminateUrl() { 
        DataSource dataSource = mock(DataSource.class);
        assertEquals(String.format("Unable to determine URL for DataSource of type %s",
                dataSource.getClass().getName()), this.dataSourceUtils.getUrl(dataSource));
    } 
 
    @Test
    public void boneCPUrl() { 
        BoneCPDataSource dataSource = new BoneCPDataSource();
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
*/ 
@Configurable 
public class TypicalSpringJpaBeans { 
    @Bean 
    public DataSource dataSource() { 
        return new SimpleDriverDataSource(new Driver(), "jdbc:h2:mem:foo;DB_CLOSE_DELAY=-1", "sa", ""); 
    } 
 
    @Bean 
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 
        vendorAdapter.setGenerateDdl(true); 
        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); 
        factoryBean.setJpaVendorAdapter(vendorAdapter); 
        factoryBean.setPersistenceProvider(new HibernatePersistence()); 
        factoryBean.setDataSource(dataSource()); 
        factoryBean.setPackagesToScan("rds.springdata"); 
        return factoryBean; 
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		} 
 
		if (jdbcUrl == null) {
			return; 
		} 
		dataSource = new SimpleDriverDataSource();
		rabbitConnectionFactory = new CachingConnectionFactory(adminServerUrl.getHost());
		try { 
			@SuppressWarnings("unchecked") Class<? extends Driver> classz =
					(Class<? extends Driver>) ClassUtils.forName(jdbcDriver, beanClassLoader);
			dataSource.setDriverClass(classz);
		} 
		catch (ClassNotFoundException e) {
			throw new IllegalStateException("failed to load class: " + jdbcDriver, e);
		} 
		String resolvedJdbcUrl = String.format(jdbcUrl, jdbcDatabase);
		dataSource.setUrl(resolvedJdbcUrl);
		if (jdbcUsername != null) {
			dataSource.setUsername(jdbcUsername);
		} 
2
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework SimpleDriverDataSource Methods: