Search code examples
javamysqldatabasejdbcjndi

What configuration properties must be set when configuring a MysqlConnectionPoolDataSource (Java)?


I want to create a MysqlConnectionPoolDataSource, but I am not sure which setter methods (setURL, setPort, setPropertiesViaRef, etc) are optional and which are required when configuring the DataSource object. Do I need to configure all of those methods, or only a few of them?


Solution

  • It depends on the configuration you would like to set however, the following parameters should be sufficient in most of the cases:

    MysqlConnectionPoolDataSource poolDataSource = new MysqlConnectionPoolDataSource();
    poolDataSource.setUser("yourUsername");
    poolDataSource.setPassword("yourPassword");
    poolDataSource.setServerName("yourServersIP");
    poolDataSource.setPort(3306);
    poolDataSource.setDatabaseName("yourDBName");