Search in sources :

Example 56 with DriverManagerDataSource

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

the class SpringJdbcConfig method mysqlDataSource.

// @Bean
public DataSource mysqlDataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost:3306/springjdbc");
    dataSource.setUsername("guest_user");
    dataSource.setPassword("guest_password");
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource)

Example 57 with DriverManagerDataSource

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

the class H2JpaConfig 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)

Example 58 with DriverManagerDataSource

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

the class StudentJpaConfig 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)

Example 59 with DriverManagerDataSource

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

the class StudentJPAH2Config 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)

Example 60 with DriverManagerDataSource

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

the class DbConfig method dataSource.

@Bean
public DataSource dataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(env.getProperty("driverClassName"));
    dataSource.setUrl(env.getProperty("url"));
    dataSource.setUsername(env.getProperty("user"));
    dataSource.setPassword(env.getProperty("password"));
    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