using GlassFish 4.0 and getting No suitable driver

2019-06-09 17:37发布

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??

2条回答
beautiful°
2楼-- · 2019-06-09 17:52

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-06-09 17:54

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.

查看更多
登录 后发表回答