ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
Properties properties = new Properties();
properties.load(new FileInputStream("src\\mysql.properties"));
String user = properties.getProperty("user");
String password = properties.getProperty("password");
String url = properties.getProperty("url");
String driver = properties.getProperty("driver");
comboPooledDataSource.setDriverClass(driver);
comboPooledDataSource.setJdbcUrl(url);
comboPooledDataSource.setUser(user);
comboPooledDataSource.setPassword(password);
comboPooledDataSource.setInitialPoolSize(10);
comboPooledDataSource.setMaxPoolSize(50);
Connection connection = comboPooledDataSource.getConnection();
connection.close();
comboPooledDataSource.close();
有两个错误,密码用户都对的
- Public Key Retrieval is not allowed
- A ResourcePool could not acquire a resource from its primary factory or source.
如果添加allowPublicKeyRetrieval=true参数,会用‘localhost’@‘localhost’不用我设置的密码
user=localhost
password=123456
url=jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8&characterEncoding=utf8&useSSL=false&useUnicode=true
driver=com.mysql.cj.jdbc.Driver