singh
singh

Reputation: 309

JDBC Driver class not found in Hibernate program

I am making a simple mapping program in hibernate.

I am facing an error:

JDBC Driver class not found: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

It gives an error on this line:

Session session = HibernateUtil.getSessionFactory().openSession();

hibernate.cfg.xml is correct. In the same configration other program are run. but this program give me error.

What is the reason that it throws this error?

Upvotes: 0

Views: 3236

Answers (1)

Rob Hruska
Rob Hruska

Reputation: 120286

You need to get a MySQL driver and put it on your classpath.

A commonly-used driver is MySQL Connector/J. It can be found here. Extract the package and make the jar available to your application.

Upvotes: 4

Related Questions