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() 

Source Link

Document

Constructor for bean-style configuration.

Usage

From source file:com.anjewe.anjewewebwinkel.Config.RootConfig.java

@Bean
public DataSource dataSource() throws SQLException {
    // drivermanagerdatasource
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(env.getRequiredProperty(DATABASE_DRIVER));
    ds.setUsername(env.getRequiredProperty(DATABASE_USERNAME));
    ds.setPassword(env.getRequiredProperty(DATABASE_PASSWORD));
    ds.setUrl(env.getRequiredProperty(DATABASE_URL));
    ds.setConnectionProperties(connectionProperties());
    return ds;//from w  w w  . j av a2  s  .c  om
}

From source file:se.ivankrizsan.messagecowboy.PersistenceConfiguration.java

/**
 * Datasource used by the Message Cowboy application.
 *//*from  w w w. java  2  s. c o  m*/
@Bean
public DataSource dataSource() {
    final DriverManagerDataSource theDataSource = new DriverManagerDataSource();
    theDataSource.setDriverClassName(dataSourceDriverClassName);
    theDataSource.setUrl(dataSourceUrl);
    theDataSource.setUsername(dataSourceUserName);
    theDataSource.setPassword(dataSourcePassword);
    return theDataSource;
}

From source file:algo.ad.feeder.ArtificialTweetsEmitterSpout.java

public ArtificialTweetsEmitterSpout(boolean isDistributed) {
    _isDistributed = isDistributed;/*w w  w  . ja v a 2 s .co  m*/

    datasource = new DriverManagerDataSource();
    datasource.setDriverClassName("com.mysql.jdbc.Driver");
    datasource.setUrl("jdbc:mysql://localhost:3306/test");// test-replica
    datasource.setUsername("root");
    datasource.setPassword("root");

    tweetsJDBCTemplate = new TweetJDBCTemplate();
    tweetsJDBCTemplate.setDataSource(datasource);

    //System.out.println("------Listing Multiple Records--------");

    //      tweets = tweetsJDBCTemplate
    //            .listTweets("select * from tweets where query_id = 2");// AND 91
    //                                                      // sentiment
    //                                                      // IN
    //                                                      // ('2')");

}

From source file:org.venzia.mdbc.service.MDBCServiceImpl.java

@Override
@SuppressWarnings("unchecked")
public void init() throws URISyntaxException {
    this.mdbcConnectors = new HashMap<String, Connector>();

    // loader by xml format
    try {//from  w  w w  .  j  a  v a2 s.c  om
        for (String connectorDeclare : connectorsDeclare) {

            InputStream connectorStream = getClass().getClassLoader().getResourceAsStream(connectorDeclare);

            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(connectorStream);

            List<Element> connector = doc.getRootElement().getChildren("connector");
            for (int i = 0; i < connector.size(); i++) {
                Element node = (Element) connector.get(i);
                // conexion a bbdd
                DriverManagerDataSource ds = new DriverManagerDataSource();
                ds.setDriverClassName(node.getChildText("driver-class-name"));
                ds.setUrl(node.getChildText("url"));
                ds.setUsername(node.getChildText("username"));
                ds.setPassword(node.getChildText("password"));

                GenericDAO dao = new GenericDAO(ds);
                List<Element> columnsNodes = node.getChild("columns").getChildren("column");
                StringBuilder build = new StringBuilder();

                Map<String, Column> columns = new HashMap<String, Column>();
                int totalColumns = 0;
                for (Element column : columnsNodes) {
                    totalColumns++;
                    Column c = new Column(column);
                    columns.put(c.getName(), c);
                    if (column.getAttributeValue("primary-key") != null) {
                        dao.setPrimaryKey(column.getAttributeValue("name"));
                    }
                    if (totalColumns == 1) {
                        build.append(c.getName());
                    } else {
                        build.append(" , " + c.getName());
                    }
                }

                dao.setQuery("SELECT " + build.toString() + " FROM " + node.getChildText("table"));

                dao.setWhere(" WHERE " + node.getChildText("where"));

                // creamos el Bus Entry
                Connector entryPoint = new ConnectorImpl(dao, node.getChildText("name"),
                        node.getChildText("aspect"));
                entryPoint.setTitle(node.getChildText("title"));
                entryPoint.setDescription(node.getChildText("description"));

                entryPoint.setColumns(columns);

                entryPoint.setColumnDetail(node.getChildText("column-detail"));

                this.mdbcConnectors.put(entryPoint.getName(), entryPoint);
            }

        }

    } catch (IOException e) {
        logger.error(e);
    } catch (JDOMException e) {
        logger.error(e);
    }

}

From source file:de.hska.ld.core.config.PersistenceConfig.java

@Bean
public DataSource dataSource() throws SQLException {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(env.getProperty("module.core.db.driver"));
    dataSource.setUrl(env.getProperty("module.core.db.url"));
    dataSource.setUsername(env.getProperty("module.core.db.username"));
    dataSource.setPassword(env.getProperty("module.core.db.password"));
    return dataSource;
}

From source file:mg.jerytodik.business.config.JeryTodikConfig.java

@Bean
public DataSource dataSource() {

    DriverManagerDataSource ds = new DriverManagerDataSource();

    ds.setDriverClassName(env.getProperty("db.driver"));
    ds.setUrl(env.getProperty("db.url"));
    ds.setUsername(env.getProperty("db.username"));
    ds.setPassword(env.getProperty("db.password"));

    return ds;//from  w  w  w  .ja  va2  s  .  c  om
}

From source file:uk.co.parso.barebones.DbConfig.java

@Bean
@Resource(name = "jdbc/test")
public DataSource testDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl(//from  w ww .  j  ava 2s .c o  m
            "jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull&amp;useUnicode=true&amp;connectTimeout=5000&amp;socketTimeout=60000");
    dataSource.setUsername("sam");
    dataSource.setPassword("sam");

    return dataSource;
}

From source file:cz.swi2.mendeluis.dataaccesslayer.core.DatabaseConfig.java

@Bean
public DataSource db() {
    DriverManagerDataSource builder = new DriverManagerDataSource();
    builder.setDriverClassName("com.mysql.jdbc.Driver");
    builder.setUrl("jdbc:mysql://127.0.0.1:3306/mendeluis?zeroDateTimeBehavior=convertToNull");
    builder.setUsername("mendeluis");
    builder.setPassword("mendeluis");

    return builder;

}

From source file:algo.ad.feeder.TwitterStreamSpout.java

public TwitterStreamSpout(String consumerKey, String consumerSecret, String accessToken,
        String accessTokenSecret, String[] keyWords) {
    this.consumerKey = consumerKey;
    this.consumerSecret = consumerSecret;
    this.accessToken = accessToken;
    this.accessTokenSecret = accessTokenSecret;
    this.keyWords = keyWords;
    String[] keyWords1 = { "#ThingsMyDoctorSays" };
    this.keyWords1 = keyWords1;

    // ********DB related stuff

    datasource = new DriverManagerDataSource();
    datasource.setDriverClassName("com.mysql.jdbc.Driver");
    datasource.setUrl(DB_BASE_URL + DB_NAME);// test-replica
    datasource.setUsername("vistaroot");
    datasource.setPassword("vista&mysql");

    tweetsJDBCTemplate = new TweetJDBCTemplate();
    tweetsJDBCTemplate.setDataSource(datasource);
}

From source file:com.qpark.eip.core.model.analysis.config.ModelAnalysisPersistence.java

/**
 * Get the {@link DataSource} auto wired in the
 * {@link EipModelAnalysisPersistenceConfig}.
 *
 * @return The {@link DataSource}/*  w  ww.j  a v  a  2s  .c  o m*/
 */
@Bean(name = EipModelAnalysisPersistenceConfig.DATASOURCE_BEAN_NAME)
public DataSource getDataSource() {
    DriverManagerDataSource bean = new DriverManagerDataSource();
    bean.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
    bean.setUrl("jdbc:hsqldb:file:src/test/hsqldb/domainDocHSQLDB.bin");
    bean.setUsername("platformUser");
    bean.setPassword("platformUserPwd");
    return bean;
}