1

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.

nerdlyist
  • 2,842
  • 2
  • 20
  • 32
  • A couple of points: [1] In your final sentence don't you mean "Driver" (or perhaps "DriverManager") rather than "Drive"? [2] Please paste the text of the actual error you are getting. You are using Glassfish 5 but the related posts you link to are nearly 5 years old and refer to Glassfish 3.1. It seems unlikely that your error is identical to those. – skomisa May 22 '18 at 20:05
  • Also, have you considered trying [Payara Server 5](https://github.com/payara/Payara) instead of Glassfish 5: _"Payara Server 5 is a **patched, enhanced, and supported application server derived from GlassFish Server Open Source Edition 5.x**"_. (I fully realize that does not address your problem at all; it's just a possible alternative approach.) – skomisa May 22 '18 at 20:11
  • @skomisa the error is exactly the same as the ones highlighted from those 5 year old ones which I found troubling. In that trouble I researched other option and found Payara which is currently being downloaded. – nerdlyist May 23 '18 at 00:37

2 Answers2

6

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 :-)

peterb
  • 76
  • 1
  • 4
  • This is correct I found this out but never updated this question with an answer. Issue was that Google kept giving me old docs. Looking on MySQL directly shows this. – nerdlyist Aug 16 '18 at 14:21
0

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

Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55