教程位置:http://forum.javaeye.com/viewtopic.php?t=834&start=0&postdays=0&postorder=asc&highlight=
jdbc驱动我加载了,并用测试类测试没有问题:详细错误信息如下,请帮帮忙.谢谢了!
代码:
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver
at net.sf.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:58)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:64)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1078)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at testhibernate.Hello.main(Hello.java:22)
Exception in thread "main"
22行也就是这句: 代码:
SessionFactory sessions = cfg.buildSessionFactory();
------解决方法--------------------------------------------------------
如果你从来没用过log4j,那就不要用log4j了。:)
------解决方法--------------------------------------------------------
: JDBC Driver class not found: com.mysql.jdbc.Driver
驱动加了?
还有,你hibernate配置文件是怎么写的?
------解决方法--------------------------------------------------------
确定log4j的JAR文件出现在classpath中!把log4j的配置文件放在classes下面!应该就不会有警告了吧