Reputation: 2847
I spent a good part of my evening setting up a Glassfish 5.0.1 server configuring a JDBC Connection Pool and deploying an application. The issue I keep running into: Unable to Connect to JDBC Connection Pool from Glassfish and GlassFish connection pool
In Glassfish for MySQL everywhere states to use the Resource Type: javax.sql.DataSource
and Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
The above never worked no matter where I put the MySQL Connector jar glassfish/lib
or domain/domain1/bin/lib
. All times I deleted the pool I had, cleared the cache and restarted the servers.
I ended up switching to java.sql.Driver
and Driver Classname: com.mysql.jdbc.Driver
Question are how do I make the Datasource work?
Also, what is the difference between Driver and Datasource?
Edit
Same issue with Payara-5. I am putting the jar in lib/ext
but the Driver failed in the same way and was resolved with it there.
Ping Connection Pool failed for MySQLConnPool2. Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details.
Upvotes: 1
Views: 3254
Reputation: 1
I had the same problems at glassfish 5.0 with mysql-connector-8.0.16.jar
. A look in the documentation of glassfish we had to place the mysql-connector-5.1.47-bin.jar
into the domains/domain1/lib directory. The connector of 8.0 has no *-bin.jar
file. So I tried to place the *5.1.47-bin.jar
into the domain1/lib directory. After the restart of my glassfish server, I tried to define a new Connection-Pool for MySQL with a javax.sql.XADataSource and the DataSourceName com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
. After setting the properties as described in glassfish documentation MySQL Server Database Type 4 Driver I got a successfull ping
Upvotes: 0
Reputation: 76
In the 5.0 to 8.0 release notes there is a reference to a change in the package name from com.mysql.jdbc to com.mysql.cj. Looking at mysql-connector-java-8.0.12.jar, there appears to be an undocumented change in the package for the data source to com.mysql.cj.jdbc.MysqlDataSource.
I have tested using com.mysql.cj.jdbc.MysqlDataSource in Payara 5 from the admin console, and it works :-)
Upvotes: 6