Search in sources :

Example 11 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project ORCID-Source by ORCID.

the class DBUnitTest method getDBConnection.

public static IDatabaseConnection getDBConnection() throws Exception {
    DriverManagerDataSource dataSource = (DriverManagerDataSource) context.getBean("simpleDataSource");
    Connection jdbcConnection = dataSource.getConnection();
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
    connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new CustomDataTypeFactory());
    return connection;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Connection(java.sql.Connection) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) IDatabaseConnection(org.dbunit.database.IDatabaseConnection)

Example 12 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project SpringStepByStep by JavaProgrammerLB.

the class DatabaseConfig method dataSource.

@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost:3306/myminitwit");
    dataSource.setUsername("root");
    dataSource.setPassword("root");
    return dataSource;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Bean(org.springframework.context.annotation.Bean)

Example 13 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project simple-java by angryziber.

the class HibernatePhotoSpotRepositoryIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dataSource = new DriverManagerDataSource("jdbc:h2:mem:hibernate;DB_CLOSE_DELAY=-1", "sa", "sa");
    System.setProperty("hibernate.dialect", H2Dialect.class.getName());
    System.setProperty("hibernate.hbm2ddl.auto", "create-drop");
    AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
    sessionFactory.setDataSource(dataSource);
    sessionFactory.setAnnotatedClasses(new Class[] { PhotoSpot.class });
    sessionFactory.afterPropertiesSet();
    repo.hibernate = new HibernateTemplate(sessionFactory.getObject());
}
Also used : H2Dialect(org.hibernate.dialect.H2Dialect) AnnotationSessionFactoryBean(org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean) DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate) Before(org.junit.Before)

Example 14 with DriverManagerDataSource

use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-framework by spring-projects.

the class RdbmsOperationTests method declareParameterAfterCompile.

@Test
public void declareParameterAfterCompile() {
    operation.setDataSource(new DriverManagerDataSource());
    operation.setSql("select * from mytable");
    operation.compile();
    exception.expect(InvalidDataAccessApiUsageException.class);
    operation.declareParameter(new SqlParameter(Types.INTEGER));
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Test(org.junit.Test)

Example 15 with DriverManagerDataSource

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;
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Bean(org.springframework.context.annotation.Bean)

Aggregations

DriverManagerDataSource (org.springframework.jdbc.datasource.DriverManagerDataSource)16 Test (org.junit.Test)8 DataSource (javax.sql.DataSource)4 Bean (org.springframework.context.annotation.Bean)3 SQLException (java.sql.SQLException)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)2 Before (org.junit.Before)2 ApplicationContextHolder (org.mifos.application.servicefacade.ApplicationContextHolder)2 ApplicationContext (org.springframework.context.ApplicationContext)2 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)2 SqlParameter (org.springframework.jdbc.core.SqlParameter)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Connection (java.sql.Connection)1 ArrayList (java.util.ArrayList)1