你的位置:首页 > Java教程

[Java教程]org.hibernate.exception.SQLGrammarException: could not execute query 没有找到数据库


org.hibernate.exception.SQLGrammarException: could not execute query	org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)	org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)	org.hibernate.loader.Loader.doList(Loader.java:2235)	org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)	org.hibernate.loader.Loader.list(Loader.java:2124)	org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)	org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)	org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)	org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)	org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)	DAO.AddressDAO.findAll(AddressDAO.java:106)	service.FAselect.execute(FAselect.java:13)	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	java.lang.reflect.Method.invoke(Method.java:597)	com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)	com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)	com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)	org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

 

root cause

com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'address' 无效。	com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)	com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)	com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)	com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)	com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)	com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)	com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)	com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)	com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285)	org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)	org.hibernate.loader.Loader.getResultSet(Loader.java:1812)	org.hibernate.loader.Loader.doQuery(Loader.java:697)	org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)	org.hibernate.loader.Loader.doList(Loader.java:2232)	org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)	org.hibernate.loader.Loader.list(Loader.java:2124)	org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)	org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)	org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)	org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)	org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)	DAO.AddressDAO.findAll(AddressDAO.java:106)	service.FAselect.execute(FAselect.java:13)	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	java.lang.reflect.Method.invoke(Method.java:597)	com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)	com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)	com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)	org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)	org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

 

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.

没有找到数据库,要么设置*.hbm.

<property name="connection.url">
   jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***
  </property>

 <class name="DAO.Address" table="address" schema="dbo" catalog="NtoN">