use of org.springframework.jdbc.datasource.DriverManagerDataSource in project rdbcache by rdbcache.
the class Configurations method dataSource.
/*
// use application.properties to configure data source
//
//@PropertySource(value = { "classpath:application.properties" })
@Autowired
Environment env;
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getRequiredProperty("spring.datasource.driver-class-name"));
dataSource.setUrl(env.getRequiredProperty("spring.datasource.url"));
dataSource.setUsername(env.getRequiredProperty("spring.datasource.username"));
dataSource.setPassword(env.getRequiredProperty("spring.datasource.password"));
return dataSource;
}
*/
// configure H2 database as data source
//
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:file:./target/testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project nikita-noark5-core by HiOA-ABI.
the class ProdDataSource method dataSource.
// beans
/*
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
//em.setPackagesToScan("no.arkivlab.hioa.nikita.client.persistence.model");
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
return em;
}*/
@Bean(name = "dataSource")
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("spring.datasource.driverClassName"));
dataSource.setUrl(env.getProperty("spring.datasource.url"));
dataSource.setUsername(env.getProperty("spring.datasource.username"));
dataSource.setPassword(env.getProperty("spring.datasource.password"));
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project RecordManager2 by moravianlibrary.
the class AppConfigDev method dataSource.
@Bean
public DataSource dataSource(@Value("${jdbc.driverClassName}") String driverClassName, @Value("${jdbc.url}") String url, @Value("${jdbc.username}") String username, @Value("${jdbc.password}") String password) {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setUrl(url);
dataSource.setPassword(username);
dataSource.setUsername(password);
DataSourceInitializer init = dataSourceInitializer(dataSource);
init.afterPropertiesSet();
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project nakadi by zalando.
the class AbstractDbRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
try {
final DataSource datasource = new DriverManagerDataSource(POSTGRES_URL, POSTGRES_USER, POSTGRES_PWD);
template = new JdbcTemplate(datasource);
connection = datasource.getConnection();
} catch (final SQLException e) {
e.printStackTrace();
}
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project narayana by jbosstm.
the class SimpleJdbcTest method getDataSource.
private static DataSource getDataSource(String user, String resourceName) throws NamingException, SQLException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
InitialContext initialContext = prepareInitialContext();
Class clazz = Class.forName("oracle.jdbc.xa.client.OracleXADataSource");
XADataSource xaDataSource = (XADataSource) clazz.newInstance();
clazz.getMethod("setDriverType", new Class[] { String.class }).invoke(xaDataSource, new Object[] { "thin" });
clazz.getMethod("setServerName", new Class[] { String.class }).invoke(xaDataSource, new Object[] { DB_HOST });
clazz.getMethod("setNetworkProtocol", new Class[] { String.class }).invoke(xaDataSource, new Object[] { "tcp" });
clazz.getMethod("setDatabaseName", new Class[] { String.class }).invoke(xaDataSource, new Object[] { DB_SID });
clazz.getMethod("setUser", new Class[] { String.class }).invoke(xaDataSource, new Object[] { user });
clazz.getMethod("setPassword", new Class[] { String.class }).invoke(xaDataSource, new Object[] { user });
clazz.getMethod("setPortNumber", new Class[] { int.class }).invoke(xaDataSource, new Object[] { 1521 });
final String name = "java:/comp/env/jdbc/" + user;
initialContext.bind(name, xaDataSource);
DriverManagerDataSource dataSource = new DriverManagerDataSource("jdbc:arjuna:" + name);
dataSource.setDriverClassName("com.arjuna.ats.jdbc.TransactionalDriver");
return dataSource;
}
Aggregations