spring与 hibernate整合 报错
log4j:WARNNoappenderscouldbefoundforlogger(org.springframework.core.env.StandardEnvir...
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.id as id0_0_, this_.username as username0_0_, this_.password as password0_0_ from demo.dbo.user this_ where this_.username=? and this_.password=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:635)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
at hiber.DAO.UserDAOImp.search(UserDAOImp.java:17)
at hiber.Biz.UserBizImp.login(UserBizImp.java:16)
at test.main(test.java:18)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at hiber.DAO.UserDAOImp$1.doInHibernate(UserDAOImp.java:28)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 4 more
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 11 more 展开
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.id as id0_0_, this_.username as username0_0_, this_.password as password0_0_ from demo.dbo.user this_ where this_.username=? and this_.password=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:635)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
at hiber.DAO.UserDAOImp.search(UserDAOImp.java:17)
at hiber.Biz.UserBizImp.login(UserBizImp.java:16)
at test.main(test.java:18)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at hiber.DAO.UserDAOImp$1.doInHibernate(UserDAOImp.java:28)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 4 more
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 11 more 展开
2个回答
展开全部
楼主你好,如果你愿意可否把你的测试代码搏雀薯发送到我邮箱【jammiwang@qq.com】,我来基者帮你调试下,调试好了再回发给你
ps:代码已经为你调试好岁世了,其实你的jar包中少了一个名为spring-tx-3.1.1.RELEASE.jar的jar包,用来进行spring的事物管理,我把你的代码重新整理了下,请下载附件参阅。
追问
为什么我修改成我的数据库配置 就会出现错误啊
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
展开全部
哦,我想比较,以确定你的中国相关的路径。
日志前面的D:\休眠解析的学习工具,就仔行变成了乱码。念汪哗文件:/ D :/%E5%AD%A6%E4%B9%A0%E5%B7%A5%E5%85%b7/Eclipse/eclipse/JAVA-HOME/spring_hibernate_1/bin/hibernate.cfg.xml 显然不承认休眠躲过了中陵芦国。在网络环境中,这个文件:/ D :/%E5%AD%A6%E4%B9%A0%E5%B7%A5%E5%85%B7可以逃脱可以识别解析。
经验,在任何情况下,不要使用中文或空格的路径环境中。
日志前面的D:\休眠解析的学习工具,就仔行变成了乱码。念汪哗文件:/ D :/%E5%AD%A6%E4%B9%A0%E5%B7%A5%E5%85%b7/Eclipse/eclipse/JAVA-HOME/spring_hibernate_1/bin/hibernate.cfg.xml 显然不承认休眠躲过了中陵芦国。在网络环境中,这个文件:/ D :/%E5%AD%A6%E4%B9%A0%E5%B7%A5%E5%85%B7可以逃脱可以识别解析。
经验,在任何情况下,不要使用中文或空格的路径环境中。
追问
F:\other\win7\MyEclipse_Last\demo 这是路径
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询