Search in sources :

Example 51 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project buffer-slayer by tramchamploo.

the class BatchJdbcTemplateTest method init.

@BeforeClass
public static void init() {
    dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.h2.Driver");
    dataSource.setUrl("jdbc:h2:~/test");
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) BeforeClass(org.junit.BeforeClass)

Example 52 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project iaf by ibissource.

the class URLDataSourceFactory method createDataSource.

protected DataSource createDataSource(String product, String url, String userId, String password, boolean testPeek, String implClassname) throws Exception {
    DriverManagerDataSource dataSource = new DriverManagerDataSource(url, userId, password);
    Properties properties = new Properties();
    properties.setProperty(PRODUCT_KEY, product);
    properties.setProperty(TEST_PEEK_KEY, "" + testPeek);
    dataSource.setConnectionProperties(properties);
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Properties(java.util.Properties)

Example 53 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project tutorials by eugenp.

the class SpringConfig method dataSource.

@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.sqlite.JDBC");
    dataSource.setUrl("jdbc:sqlite:repository.sqlite");
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) JobRepositoryFactoryBean(org.springframework.batch.core.repository.support.JobRepositoryFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 54 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project tutorials by eugenp.

the class MySQLAutoconfiguration method dataSource2.

@Bean(name = "dataSource")
@ConditionalOnProperty(name = "usemysql", havingValue = "custom")
@ConditionalOnMissingBean
public DataSource dataSource2() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
    dataSource.setUrl(env.getProperty("mysql.url"));
    dataSource.setUsername(env.getProperty("mysql.user") != null ? env.getProperty("mysql.user") : "");
    dataSource.setPassword(env.getProperty("mysql.pass") != null ? env.getProperty("mysql.pass") : "");
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 55 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project tutorials by eugenp.

the class PersistenceConfig method dataSource.

@Bean
public DataSource dataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    dataSource.setUrl(env.getProperty("jdbc.url"));
    dataSource.setUsername(env.getProperty("jdbc.user"));
    dataSource.setPassword(env.getProperty("jdbc.pass"));
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

DriverManagerDataSource (org.springframework.jdbc.datasource.DriverManagerDataSource)67 Bean (org.springframework.context.annotation.Bean)29 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)20 Test (org.junit.jupiter.api.Test)9 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)8 DataSource (javax.sql.DataSource)7 SQLException (java.sql.SQLException)4 Properties (java.util.Properties)4 PersistenceUnitInfo (jakarta.persistence.spi.PersistenceUnitInfo)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 InitialContext (javax.naming.InitialContext)2 XADataSource (javax.sql.XADataSource)2 Before (org.junit.Before)2 ApplicationContextHolder (org.mifos.application.servicefacade.ApplicationContextHolder)2 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)2