There is no suitable MySQL driver for the JBoss application

I am new to creating Java web applications and encountered this problem when trying to interact with my database (called ccdb) through my application:

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/ccdb/

My application runs on JBoss and uses Hibernate to interact with the MySQL database. I have a MySQL driver in lib \ mysql-connector-java-5.1.6-bin.jar of my project, and I have a .jar configured in Eclipse as a "Java EE module dependency" so that it is copied to the web inf \ lib \ when I deploy it to JBoss via Eclipse. I checked twice, and the driver is definitely located in the .war file with the project, so you need to find it, right?

My hibernate.cfg.xml contains this line, which should indicate hibernation on the driver.

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

Does anyone know what I need to do to make this work? Do I need to configure a MySQL database as a JBoss data source to work?

Thanks in advance.

Edit: the kauppi solution works, but I would rather have it in lib \ with other banks, and I am very curious why this will not work. Any ideas ...?

+3
source share
2 answers

This may be the best way to do this, but I usually copied the MySQL JAR connector to jboss \ server \ default \ lib (assuming you are using the default configuration).

+4
source

placing external libraries in the lib folder is bad practice.

You need to edit the file:

server / $ {server_name} /conf/jboss-service.xml and add

<classpath codebase="${jboss.server.lib.url:lib}ext" archives="*"/>

after

<classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>

: server/${servername}/lib/ext

.

+4

Source: https://habr.com/ru/post/1698554/


All Articles