【问题标题】:Configure SSL in dbcp2.BasicDataSource在 dbcp2.BasicDataSource 中配置 SSL
【发布时间】:2017-09-22 19:44:36
【问题描述】:

我想添加 enable ssl 、 ssltrustoreLocation 和 ssltrustorepassword for BasicDataSource,谁能告诉我如何添加。

    BasicDataSource dataSource = new BasicDataSource();  //NOSONAR
    dataSource.setDriverClassName(driverName);
    dataSource.setUrl(url);
    dataSource.setUsername(userName);
    dataSource.setPassword(password);
    dataSource.setMaxWaitMillis(Integer.parseInt(dbMaxWaitTime));
    dataSource.setMinIdle(Integer.parseInt(dbMinPoolSize));
    dataSource.setMaxIdle(Integer.parseInt(dbMaxPoolSize));

【问题讨论】:

    标签: database ssl db2 datasource truststore


    【解决方案1】:

    我不确定我们是否可以拥有 BasicDataSource 的 ssltrustoreLocation 和密码。但是您可以在服务器配置中实现它。要连接数据库,您需要配置 SSL 数据库模式,并且可以使用用户名和密码与其连接。 在我的项目中,我们在服务器级别配置了 SSL,并且我们使用用户名和密码连接 SSL 数据库模式。

    【讨论】: