Roshan
Roshan

Reputation: 645

using GlassFish 4.0 and getting No suitable driver found for jdbc:mysql error

the following error i am getting;

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/chh-cw
root cause

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/chh-cw

the following is my project structure:

enter image description here

is this the correct path to put the external jars??

Upvotes: 0

Views: 3669

Answers (2)

software-undercover
software-undercover

Reputation: 72

yes - if you do your Connection in an may LoginServerlet... with Code like this:

this.conn = DriverManager.getConnection(getConnString());

you only have to copy the mysql..connector.jar to the WEB-Inf/lib Folder or your Domain.

Upvotes: 0

wrschneider
wrschneider

Reputation: 18800

It depends. Who is actually creating the connection? If your application code is directly, then the JAR belongs in WEB-INF/lib. If your container is managing the connections through a JNDI resource, then the JAR needs to be in the Glassfish classpath, not WEB-INF/lib.

In Glassfish 3.x I put the JARs in domain/lib/ext or something like that.

Upvotes: 1

Related Questions