日期:2014-05-20  浏览次数:20744 次

Hibernate框架中,log4j异常问题。求各位大神帮帮忙!
log4j:ERROR Failed to excute sql
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@90.0.12.20:1521:ORCL
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders (AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:157)
at net.sf.ehcache.config.Configurator.configure(Configurator.java:126)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:166)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:138)
at net.sf.ehcache.CacheManager.create(CacheManager.java:193)
at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:130)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:173)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.cn.hibernate.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31)
at com.cn.test.TestHibernate.main(TestHibernate.java:35)

log4j的部分配置:
log4j.appender.DATABASE.sql 
INSERT INTO T_LOG4J(stamp,thread,infolevel,class,messages) VALUES ('%d{yyyy-MM-dd HH:mm:ss}', '%t', '%p', '%l', '%m')


------解决方案--------------------
问题就是没有jdbc驱动。
把jdbc的jar文件添加到classpath中,如果是web项目,将其放到WEB-INF/lib目录下

#呵呵,第一次看到用log4j把log存数据里的。

------解决方案--------------------
代码发上来看看
------解决方案--------------------

log4j.rootLogger=DEBUG,CONSOLE,DATABASE,A1
中的DATABASE去掉就可以了
变成
log4j.rootLogger=DEBUG,CONSOLE,A1
------解决方案--------------------

真是没完没了的问题,你那个问题已经解决了,就应该结贴了,这是一个新问题

探讨

刚才那个解决了,谢谢!这个是问什么呀?

[framework] 2012-08-22 19:50:30,984 - org.hibernate.tool.hbm2ddl.TableMetadata -796 [main] INFO org.hibernate.tool.hbm2ddl.TableMetadata - indexes: [primary]
[framework] 20……