Spring Framework DriverManagerDataSource - 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 DriverManagerDataSource class.

This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
 * @author Luke Taylor 
 */ 
public class TestDataSource extends DriverManagerDataSource implements DisposableBean { 
    String name; 
 
    public TestDataSource(String databaseName) { 
        name = databaseName; 
        System.out.println("Creating database: " + name); 
        setDriverClassName("org.hsqldb.jdbcDriver"); 
        setUrl("jdbc:hsqldb:mem:" + databaseName); 
        setUsername("sa"); 
        setPassword(""); 
    } 
 
    public void destroy() throws Exception { 
        System.out.println("Shutting down database: " + name); 
        new JdbcTemplate(this).execute("SHUTDOWN"); 
    } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
	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;
	} 
 
	private void populateDataBase() throws Exception {
		ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
		databasePopulator.addScript(new ClassPathResource("test-data.sql", this.getClass()));
		DataSourceInitializer initializer = new DataSourceInitializer();
		initializer.setDataSource(getDataSource());
		initializer.setDatabasePopulator(databasePopulator);
		initializer.afterPropertiesSet();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
    this.databasePrefix = this.databaseDir.toURI().toString();
     
    this.h2JdbcUrl.setDatabasePrefix(this.databasePrefix);
    this.object.setH2JdbcUrl(this.h2JdbcUrl);
     
    this.dataSource.setDriverClassName("org.h2.Driver");
    this.dataSource.setUrl(this.h2JdbcUrl.getUrl());
    this.dataSource.setUsername("sa");
    this.dataSource.setPassword("");
    this.object.setDataSource(this.dataSource);
     
    DatabaseSchema schema = new DatabaseSchema();
    schema.setJdbcTemplate(new JdbcTemplate(this.dataSource));
    this.object.setDatabaseSchema(schema);
     
    this.object.setUsername("sa");
    this.object.setPassword("");
     
    Transaction transaction = new Transaction();
    transaction.setTransactionManager(new DataSourceTransactionManager(this.dataSource));

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
		return ds;
	} 
	 
	static long hsqlDbIdSequence = 0;
	public static synchronized DataSource getDataSource() {
		DriverManagerDataSource ds = new DriverManagerDataSource();
		ds.setDriverClassName("org.hsqldb.jdbcDriver");
		ds.setUrl("jdbc:hsqldb:mem:memDB"+System.currentTimeMillis()+""+(hsqlDbIdSequence++));
		ds.setUsername("sa");
		ds.setPassword("");
		return ds;
	} 
 
	public static void executeSqlScripts(Reader initScripts,DataSource ds) throws SQLException, IOException {
		Connection conn = ds.getConnection();
		try { 
			String sql = IOUtils.toString(initScripts);
			StringTokenizer tokenizer = new StringTokenizer(sql,";");
			System.out.println("Execute HSQL DB DataSource with sql:");
			while(tokenizer.hasMoreTokens()) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
	@BeforeClass 
	public static void setUpBeforeClass() throws Exception {
		Logger dslogger = Logger.getLogger(DriverManagerDataSource.class
				.getName());
		dslogger.setLevel(Level.OFF);
		dataSource = new DriverManagerDataSource();
		dataSource.setDriverClassName("org.h2.Driver");
		dataSource.setUrl("jdbc:h2:mem:webscarab3;DB_CLOSE_DELAY=-1");
		dataSource.setUsername("sa");
		dataSource.setPassword("");
		dao = new JdbcMessageDAO();
		dao.setDataSource(dataSource);
	} 
 
	@Before 
	public void setUp() { 
		dao.createTables();
	} 
 
	@After 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
		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; 
	} 
 
	private void populateDataBase(DataSource dataSource) throws Exception { 
		ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); 
		databasePopulator.addScript(new ClassPathResource("test-data.sql", this.getClass())); 
		DataSourceInitializer initializer = new DataSourceInitializer(); 
		initializer.setDataSource(dataSource); 
		initializer.setDatabasePopulator(databasePopulator); 
		initializer.afterPropertiesSet(); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
			} 
		} 
	} 
 
	static DriverManagerDataSource createTestDataSource() {
		DriverManagerDataSource dataSource = new DriverManagerDataSource();
		dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
		dataSource.setUrl("jdbc:hsqldb:mem:mindatabase");
		dataSource.setUsername("sa");
		dataSource.setPassword("");
		return dataSource;
	} 
 
	@Override 
	public String toString() {
		StringBuilder sb = new StringBuilder("{\n");
		Class<? extends ServiceContext> clazz = getClass();
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			String name = field.getName();
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setDriverClassName, setPassword, setUrl, setUsername
See Code Examples for Spring Framework DriverManagerDataSource Methods: