Error Message: No suitable driver found for jdbc:mysql:.. in a maven jpa/hibernate/mysql project

Problem Statement

In your maven project, with appropriate dependencies for Hibernate/MySQL, you get the following error – when jpa-hibernate code is invoked:

WARN : org.hibernate.connection.DriverManagerConnectionProvider – no JDBC Driver class was specified by property hibernate.connection.driver_class
WARN : org.hibernate.cfg.SettingsFactory – Could not obtain connection to query metadata
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/somedb

Solution

The solution is in the warning itself. Note the line that says:  no JDBC Driver class was specified by property hibernate.connection.driver_class

In your persistence.xml file add the following line:
<property name=”hibernate.connection.driver_class” value=”com.mysql.jdbc.Driver” />

That’s It!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: