List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource
public DriverManagerDataSource(String url, String username, String password)
From source file:com.yahoo.sql4d.indexeragent.sql.DBAccessor.java
@Override public Tuple2<DataSource, Connection> makeObject() throws Exception { DataSource ds = new DriverManagerDataSource(format(connectorUrl, host, port, db), id, password); return new Tuple2<>(ds, ds.getConnection()); }
From source file:com.capgemini.archaius.spring.ArchaiusSpringPropertyPlaceholderSupport.java
private DriverManagerDataSource buildDataSourceFromConnectionDetailsMap( Map<String, String> jdbcConnectionDetailMap) { DriverManagerDataSource ds = new DriverManagerDataSource(jdbcConnectionDetailMap.get(JdbcContants.DB_URL), jdbcConnectionDetailMap.get(JdbcContants.USERNAME), jdbcConnectionDetailMap.get(JdbcContants.PASSWORD)); ds.setDriverClassName(jdbcConnectionDetailMap.get(JdbcContants.DB_DRIVER)); return ds;/* w ww.jav a 2s. c o m*/ }
From source file:nz.geek.caffe.spring.hdb.HANAExceptionMappingTest.java
/** *//*from w ww . ja v a 2 s. com*/ @Test public void testUnableToConnect() { final DriverManagerDataSource ds = new DriverManagerDataSource("jdbc:sap://blahhost:30115", "blah", "blah"); JdbcTemplate template = new JdbcTemplate(); template.setExceptionTranslator(new SQLErrorCodeSQLExceptionTranslator("HDB")); template.setDataSource(new LazyConnectionDataSourceProxy(ds)); template.afterPropertiesSet(); try { template.execute("SELECT 1 FROM DUMMY"); Assert.fail("connect should have failed"); } catch (final DataAccessResourceFailureException e) { // expected } }
From source file:org.apache.syncope.client.cli.commands.MigrateTest.java
@Test public void conf() throws Exception { // 1. migrate String[] args = new String[4]; args[0] = "migrate"; args[1] = "--conf"; args[2] = BASE_PATH + File.separator + "content12.xml"; args[3] = BASE_PATH + File.separator + "MasterContent.xml"; new MigrateCommand().execute(new Input(args)); // 2. initialize db as persistence-jpa does DataSource dataSource = new DriverManagerDataSource("jdbc:h2:mem:syncopedb;DB_CLOSE_DELAY=-1", "sa", null); new ResourceDatabasePopulator(new ClassPathResource("/schema20.sql")).execute(dataSource); // 3. attempt to set initial content from the migrated MasterContent.xml SAXParserFactory factory = SAXParserFactory.newInstance(); InputStream in = null;//from w w w. java 2 s .c o m try { in = new FileInputStream(args[3]); SAXParser parser = factory.newSAXParser(); parser.parse(in, new ContentLoaderHandler(dataSource, ROOT_ELEMENT, false)); } finally { IOUtils.closeQuietly(in); } }