Java Code Examples for org.springframework.jdbc.datasource.SingleConnectionDataSource#setDriverClassName()

The following examples show how to use org.springframework.jdbc.datasource.SingleConnectionDataSource#setDriverClassName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Given("^(?:D|d)atabase connection$")
public void setConnection(DataTable properties) {
    Map<String, String> connectionProps = properties.asMap(String.class, String.class);

    String driver = connectionProps.getOrDefault("driver", "org.postgresql.Driver");
    String url = connectionProps.getOrDefault("url", "jdbc:postgresql://localhost:5432/testdb");
    String username = connectionProps.getOrDefault("username", "test");
    String password = connectionProps.getOrDefault("password", "test");
    boolean suppressClose = Boolean.parseBoolean(connectionProps.getOrDefault("suppressClose", Boolean.TRUE.toString()));

    SingleConnectionDataSource singleConnectionDataSource = new SingleConnectionDataSource(url, username, password, suppressClose);
    singleConnectionDataSource.setDriverClassName(driver);
    this.dataSource = singleConnectionDataSource;
}
 
Example 2
Source File: Utils.java    From jql with MIT License 4 votes vote down vote up
public static SingleConnectionDataSource getDataSourceFrom(String databaseFile) {
    SingleConnectionDataSource dataSource = new SingleConnectionDataSource();
    dataSource.setDriverClassName("org.sqlite.JDBC");
    dataSource.setUrl("jdbc:sqlite:" + databaseFile);
    return dataSource;
}