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

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

Introduction

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

Prototype

public SimpleDriverDataSource(Driver driver, String url, Properties conProps) 

Source Link

Document

Create a new DriverManagerDataSource with the given standard Driver parameters.

Usage

From source file:annis.administration.DefaultAdministrationDao.java

private DataSource createDataSource(String host, String port, String database, String user, String password,
        boolean useSSL) {
    Properties props = new Properties();
    String url = "jdbc:postgresql://" + host + ":" + port + "/" + database;

    if (useSSL) {
        props.put("ssl", "true");
    }/*w  w  w  .j  a  va 2  s  . c  o  m*/
    // DriverManagerDataSource is deprecated
    // return new DriverManagerDataSource("org.postgresql.Driver", url, user, password);

    props.put("user", user);
    props.put("password", password);

    // why is this better?
    // XXX: how to construct the datasource?
    return new SimpleDriverDataSource(new Driver(), url, props);
}