Tuesday, June 09, 2009

Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource

If you get this error when trying to ping a newly created JDBC connection pool from within GlassFish admin console, it's likely because you're missing the JDBC driver mysql-connector-java-5.1.*-bin.jar under the lib/ext folder on your domain. 


To fix it copy that file there (e.g. ~/glassfish-v2ur2/domains/domain1/lib/ext/mysql-connector-java-5.1.5-bin.jar ), restart the domain and try again.

You can get the latest copy of the driver from here.


Update: There was at least a comment below, indicating that this method may not work for GlassFish version 3.1.1 and the more recent JDBC connection drivers. Your best bet may be to use the official docs, for the particular version of GlassFish you're running. For 3.1.1 one doc and another doc indicates that mysql-connector-java-5.1.14-bin.jar should be placed under the lib folder, not under lib/ext folder. 

27 comments:

Anonymous said...

Thanks for the best and Short answer. Thanks a lot.

IchBinRene said...

Add one to the gratefulness list.

CIpri said...

Multumesc Bogdan!

Anonymous said...

Thanks a lot

Anonymous said...

Thanks

Anonymous said...

Thank you very much, you helped us a lot. You save our project's score

Anonymous said...

thanks it helped me as well

Anonymous said...

what are other possible errors even thought I have placed the connector in the filepath?

Anonymous said...

thanksssssssss you are are my hero!

Anonymous said...

Thank god man...that you have provided such a useful piece of information...It helped me when i lost all my hopes...May god take you to greater heights..God Bless!!!!

Anonymous said...

This does not work for driver 5.1.17 on glassfih v3.1.1 . Everywhere I read about the problem is offering to copy it in a different path?

Cengiz C. said...

You sir, saved my sanity twice. Thanks twice.

Anonymous said...

you are right it works exactly. Here is what i did to solve the problem. I have downloaded the latest version ie Connector/J 5.1.18 from http://dev.mysql.com/downloads/connector/j/5.1.html web site address and i unziped the file. Then simple step i just got to my Glass fish installation folder[eg.C:\....\domains\domain1\lib\ext and put the mysql-connector-java-5.1.18-bin.jar file. restart the glassfish server then every thing goes well. thxs guys

animeworld said...

Thank you!

Anonymous said...

You saved me man!! ;)

M. Aamir said...

Thanks
It worked for me.

Anonymous said...

Obrigado pela solução !
um abraço

Mathieu Charest-Durand said...

thx

Anonymous said...

You made my day ;)

Anonymous said...

thankssssss from barcelona!!!!!!!!!

Anonymous said...

Thanks a Lot for perfect answer.

Unknown said...

it will work if placed under lib folder not under your domain1 but lib directory which under domain please check this

Anonymous said...

Merci beaucoup les gars !
Thanks a lot guys !

Anonymous said...

Works perfectly thanks buddy

Anonymous said...

Thank you a lot

Anonymous said...

Thanks!!

Anonymous said...

Thanks! For GlassFish 5, you need to copy to the next dest (Windows): ..\glassfish5\glassfish\lib\