开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜