Why DataSource interface does not define the Standard Data Source Properties specified by the JDBC – DataSource?
With a reference dsof the DataSource type I cannot set the following properties like this:
public DbUtil(DataSource ds, String dbName, String port){
ds.setServerName(dbName);
ds.setPortNumber(port);
}
Because you’re not supposed to pass in those values unlike plain old
DriverManager. A DataSource is normally configured on the container and only looked-up using JNDI.If you again start passing in these values, it defeats the whole point of having configurable DataSources.
Here is a quote from the API.