Biohazard401
Biohazard401

Reputation: 41

Class name is wrong or classpath is not set for : com.mysql.jdbc.Driver

I want to configure glassfish with my db. I create jdbc ressource like this:

And i create my connection pool like this:

in Additional Properties

I add mysql-connecter-java and com.mysql.jdbc in "glassfish4/glassfish/domains/domain1/lib/ext"

And when i ping my connection with the site glassfish, i have this message

Ping Connection Pool failed for MySqlConnPoll. Class name is wrong or classpath is not set for : com.mysql.jdbc.Driver Please check the server.log for more details.

Why i have this message ? i forgot something ?

thanks

Upvotes: 2

Views: 13328

Answers (2)

Uwe Bretschneider
Uwe Bretschneider

Reputation: 1281

it seems that your driver name is wrong.

For ConnectorJ version 8 try:

com.mysql.cj.jdbc.MysqlDataSource

For older ones:

com.mysql.jdbc.jdbc2.optional.MysqlDataSource

This is how to configure the Datasource Classname field for MySQL 8:

Datasource Classname setting

Upvotes: 3

user3707912
user3707912

Reputation: 11

I've just learnt JDBC last week, not sure I can help.

I have got something like this too after creating a new domain in glassfish4.0 and try to create a connection pool with that new domain. After a few tries and errors, I got it to work.

I added the connector .jar in "glassfish4/glassfish/domains/domain1/lib" rather than inside the "glassfish4/glassfish/domains/domain1/lib/ext" like you mention. Maybe you can try that and see.

not sure if this help: while connecting to database, I also use the same .jar (meaning pointing to the same file) when specifying the driver.

Upvotes: 1

Related Questions