views:

37

answers:

1

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?

+4  A: 

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.

Rob Hruska