我想为 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));
最佳答案
我不确定我们是否可以为 BasicDataSource 提供 ssltrustoreLocation 和密码。但是您可以在服务器配置中实现它。要连接数据库,您需要配置 SSL 数据库模式,并且可以使用用户名和密码连接它。 在我的项目中,我们在服务器级别配置了 SSL,并且我们有 SSL 数据库架构,我们使用用户名和密码连接。
关于database - 在 dbcp2.BasicDataSource 中配置 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43616680/