Example usage for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource

List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource.

Prototype

public DriverManagerDataSource(String url, String username, String password) 

Source Link

Document

Create a new DriverManagerDataSource with the given standard DriverManager parameters.

Usage

From source file:org.sakaiproject.genericdao.springjdbc.ReallyCrazyGenericDaoTest.java

@SuppressWarnings("deprecation")
@BeforeClass//from ww  w.  j  a v a 2  s  .co  m
public static void initDAO() {
    // create and startup embedded HSQLDB
    DriverManagerDataSource dataSource = new DriverManagerDataSource("jdbc:hsqldb:.", "sa", "");
    assertNotNull(dataSource);

    // create and set the data mappers (one for each table)
    SimpleDataMapper crazyMapper = new SimpleDataMapper(CrazyTestObject.class, "id", "CRAZY_TEST_OBJECT2");
    crazyMapper.setDBTypeToFile(
            SimpleDataMapper.makeDDLMap("gto.sql", new String[] { DatabaseTranslator.DBTYPE_HSQLDB }, "sql"));

    // start up the dao class with threadbound datasource and auto-commit
    jdbcGenericDao = new JdbcGeneralGenericDao(dataSource, true, DatabaseTranslator.DBTYPE_HSQLDB, true, true,
            new DataMapper[] { crazyMapper });
    jdbcGenericDao.setAutoCommitOperations(false);
    jdbcGenericDao.startup();

    jdbcGenericDao.commitTransaction(); // clear anything pending

    // set the var used for testing
    genericDao = jdbcGenericDao;
}

From source file:com.seovic.datasource.DriverManagerDataSourceFactory.java

public DataSource createDataSource() {
    return new DriverManagerDataSource(m_url, m_username, m_password);
}

From source file:com.stehno.test.TestDatabase.java

@Override
protected void before() throws Throwable {
    // org.h2.Driver
    jdbcTemplate = new JdbcTemplate(new DriverManagerDataSource("jdbc:h2:~/test", "sa", ""));

    namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);

    jdbcTemplate.execute(//  ww w . j  ava2s  .  co  m
            "create table people (id int AUTO_INCREMENT primary key, first_name varchar(40), last_name varchar(40), age int)");
}

From source file:com.apress.prospringintegration.springenterprise.stocks.config.StocksBaseConfig.java

@Bean
public DataSource remoteDataSource() {
    return new DriverManagerDataSource(jdbcUrl, username, password);
}

From source file:cn.net.withub.demo.bootsec.hello.config.SpringDataConfig.java

/**
 * ??//from  w ww  .  ja  va  2  s .  c  om
 *
 * @return
 */
@Bean
public DriverManagerDataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource(url, userName, password);
    dataSource.setDriverClassName(driverClassName);
    return dataSource;
}

From source file:info.novatec.flyway.branching.extension.BranchingMigrationPostgresqlIntegrationTest.java

@Override
protected DataSource getDatasource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource(getJdbcUrl(), getUserName(),
            getPassword());/*from   w w  w . j a va2  s  . c  o m*/
    dataSource.setDriverClassName("org.postgresql.Driver");
    return dataSource;
}

From source file:com.p6spy.engine.spy.P6TestUtil.java

public static void setupTestData(final String url, final String username, final String password)
        throws LiquibaseException {

    // setup database for testing
    String nativeUrl = url;/* w w w.j  a  v  a  2s  .c om*/
    if (url.startsWith("jdbc:p6spy:")) {
        nativeUrl = url.replace("jdbc:p6spy:", "jdbc:");
    }

    setupTestData(new DriverManagerDataSource(nativeUrl, username, password));
}

From source file:nz.geek.caffe.hdb.hibernate.demo.TestEmployee.java

/**
 *//*from   w ww  . ja v a2s.c o m*/
@Before
public void setUp() {
    final DataSource ds = new DriverManagerDataSource(
            System.getProperty("jdbc.url", "jdbc:sap://localhost:30115"),
            System.getProperty("jdbc.user", "hibernate"), System.getProperty("jdbc.password", "hibernate"));

    final LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(ds);
    builder.setProperty(AvailableSettings.DIALECT,
            System.getProperty("hibernate.dialect", HANAColumnStoreDialect.class.getName()));
    builder.setProperty(AvailableSettings.HBM2DDL_AUTO, "create-drop");
    builder.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");

    builder.addAnnotatedClass(Employee.class);

    this.sessionFactory = builder.buildSessionFactory();

    final HibernateTemplate ht = new HibernateTemplate();
    ht.setSessionFactory(this.sessionFactory);

    ht.afterPropertiesSet();

    this.template = ht;

    final HibernateTransactionManager txnMgr = new HibernateTransactionManager();
    txnMgr.setDataSource(ds);
    txnMgr.setSessionFactory(this.sessionFactory);
    txnMgr.afterPropertiesSet();

    this.transactionTemplate = new TransactionTemplate(txnMgr);
}

From source file:de.brands4friends.daleq.integration.config.MysqlConfig.java

@Bean
public DataSource dataSource() {

    final String url = readProperty(MYSQL_URL);
    final String user = readProperty(MYSQL_USER);
    final String password = readProperty(MYSQL_PASSWORD);

    return new DriverManagerDataSource(url, user, password);
}

From source file:com.seovic.core.factory.DriverManagerDataSourceFactory.java

/**
 * {@inheritDoc}
 */
public DataSource create() {
    return new DriverManagerDataSource(url, username, password);
}