Connecting a MySQL database to Glassfish classpath is not set or classname is wrong

后端 未结 5 1361
情深已故
情深已故 2020-12-28 14:47

I\'m swapping out a derby database for a MySQL one. I had everything working before but after what I thought was the proper configuration I\'m getting the error:

Cau

相关标签:
5条回答
  • 2020-12-28 15:08

    I copied the jar file to $glassfish_install_folder\glassfish\lib, after that it worked. I use glassfish 4.0.

    Check this link from oracle.

    0 讨论(0)
  • 2020-12-28 15:10

    Looks like I am replying very late, but however people who would be referring to this thread may find the following information being useful. So I am posting it here:

    1. Download the connector Jar from http://dev.mysql.com/downloads/connector/j/5.0.html
    2. unzip the pack and copy mysql-connector-java-verno-bin.jar
    3. past the same at [GlassFish Installation Directory]/domains/[domain name]/lib folder
    4. restart your domain and ping to check your connection in JDBC Connection Pools

    There you go. If your MySql is running then it will ping the DB successfully

    0 讨论(0)
  • 2020-12-28 15:12

    I encountered this issue in 2019 and would like to note that if you are using docker image payara/server-full (I am using 5.194 so far) as I do the location to place the driver jar is:

    /opt/payara/appserver/glassfish/domains/production/lib/

    In the end I am doing something like this in the Dockerfile of payara server:

    RUN wget http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.2.0/mariadb-java-client-2.2.0.jar \
        -O /opt/payara/appserver/glassfish/domains/production/lib/mariadb-java-client-2.2.0.jar
    
    0 讨论(0)
  • 2020-12-28 15:19

    I encountered this issue in 2018 and would like to note that if you are using glassfish 4 (current is 5) then it seems you have to use the Connector/J 5.1.47 version for it to work. If you use the current version (Connector/J 8.0.13) then exception mentioned in the original question keeps appearing, no matter where you place the .jar file.

    With Connector/J 5.1.47 it works perfectly.

    0 讨论(0)
  • 2020-12-28 15:34

    I've also added the MySQL driver .jars to the library of glassfish in both projects.

    It was apparently not done right. The JAR has to go in /glassfish/domains/[domainname]/lib/ext folder of the Glassfish installation where [domainname] usually defaults to domain1. You can and should not configure it from the Eclipse side on.

    0 讨论(0)
提交回复
热议问题