use of org.springframework.jdbc.datasource.DriverManagerDataSource in project av-service by dvoraka.
the class DbConfig method dataSource.
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(driver);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(pass);
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-data-jdbc by spring-projects.
the class OracleDataSourceConfiguration method createDataSource.
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
*/
@Override
protected DataSource createDataSource() {
if (ORACLE_CONTAINER == null) {
LOG.info("Oracle starting...");
OracleContainer container = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim").withReuse(true);
container.start();
LOG.info("Oracle started");
ORACLE_CONTAINER = container;
}
initDb();
return new DriverManagerDataSource(ORACLE_CONTAINER.getJdbcUrl(), ORACLE_CONTAINER.getUsername(), ORACLE_CONTAINER.getPassword());
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project rdbcache by rdbcache.
the class DataSourceConfig method systemDataSource.
@Bean
public DataSource systemDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("system.datasource.driver-class-name"));
dataSource.setUrl(env.getProperty("system.datasource.url"));
dataSource.setUsername(env.getProperty("system.datasource.username"));
dataSource.setPassword(env.getProperty("system.datasource.password"));
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project rdbcache by rdbcache.
the class DataSourceConfig method dataSource.
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("spring.datasource.driver-class-name"));
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 buffer-slayer by tramchamploo.
the class AbstractTimeUsedComparison method run.
protected void run() throws Exception {
BatchJdbcTemplate batch;
JdbcTemplate unbatch;
SenderProxy proxy;
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl(propertyOr("jdbcUrl", "jdbc:mysql://127.0.0.1:3306?useSSL=false"));
dataSource.setUsername(propertyOr("username", "root"));
dataSource.setPassword(propertyOr("password", "root"));
JdbcTemplate delegate = new JdbcTemplate(dataSource);
delegate.setDataSource(dataSource);
AtomicLong counter = new AtomicLong();
final String CREATE_DATABASE = "CREATE DATABASE IF NOT EXISTS test";
final String CREATE_TABLE = "CREATE TABLE test.benchmark(id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(32), time TIMESTAMP)";
final String DROP_TABLE = "DROP TABLE IF EXISTS test.benchmark";
final String INSERTION = "INSERT INTO test.benchmark(data, time) VALUES(?, ?)";
final String MODIFICATION = "UPDATE test.benchmark SET data = ? WHERE id = ?";
CountDownLatch countDown = new CountDownLatch(1);
proxy = new SenderProxy(new JdbcTemplateSender(delegate));
proxy.onMessages(updated -> {
if (counter.addAndGet(updated.size()) == 5050) {
countDown.countDown();
}
});
Reporter<Sql, Integer> reporter = reporter(proxy);
batch = new BatchJdbcTemplate(delegate, reporter);
batch.setDataSource(dataSource);
unbatch = new JdbcTemplate(dataSource);
unbatch.setDataSource(dataSource);
unbatch.update(CREATE_DATABASE);
unbatch.update(DROP_TABLE);
unbatch.update(CREATE_TABLE);
Random random = new Random(System.currentTimeMillis());
long start = System.nanoTime();
for (int i = 0; i < 5000; i++) {
batch.update(INSERTION, randomString(), new Date());
if (i % 100 == 0) {
batch.update(MODIFICATION, randomString(), random.nextInt(i + 1) + 1);
}
}
countDown.await();
long used = System.nanoTime() - start;
System.out.printf("batch time used: %15d\n", used);
reporter.close();
unbatch.update(DROP_TABLE);
unbatch.update(CREATE_TABLE);
start = System.nanoTime();
for (int i = 0; i < 5000; i++) {
unbatch.update(INSERTION, randomString(), new Date());
if (i % 100 == 0) {
unbatch.update(MODIFICATION, randomString(), random.nextInt(i + 1) + 1);
}
}
used = System.nanoTime() - start;
System.out.printf("unbatch time used: %15d", used);
unbatch.update(DROP_TABLE);
}
Aggregations