As soon the getConnection method is called on an instance of MySQLDataSource a connection URL is constructed and cached.
The cached URL isn't cleared/reconstructed during a call to setPort/setDatabaseName/setServerName.
To reproduce it is important to call getConnection before changed on of
the properties, because as long getConnection hasn't been called, the
internal method createURL isn't called. The method creates a connection based on set properties, if the reference to the url is NULL. Hence the next
call just returns the cached URL, without taking any changes to port/databasename/servername into consideration.
I think it is easily fixable with just setting the url reference on NULL if a method of setPort/setDatabaseName/setServerName is called.