Creating a connection pool should be a simple and straight forward task in an application server but sometimes it just becomes unnecessarily difficult. That is completely true for creating MySQL connections pools in all versions of GlassFish from 3 onwards.
The problem is that GlassFish provides the wrong name for the URL parameter when setting up a MySQL connection pool Rather than the correct URL it provides Url. Only a slight difference but enough to cause stack traces that end with this exception:
Caused by: java.sql.SQLException: No database selected at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
The easiest fix is to just rename the parameter to URL. I also provide the username and password in the URL like this:
jdbc:mysql://127.0.0.1:3306/core?user=user&password=password
Oddly the ping function from inside GlassFish works fine, I think what is happening is the ping function uses the separate parameters to build a connection string but the applications use the connection string directly. The application is calling setUrl on the driver but the method is actually called setURL.