访问SPring MVC应用程序时出错

时间:2013-07-09 22:12:08

标签: hibernate spring-mvc ubuntu

您好我在Ubuntu上的tomcat服务器上部署了一个Web应用程序。但我在登录时遇到以下错误。

HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

message Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
description The server encountered an internal error that prevented it from fulfilling this request.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
org.hibernate.exception.SQLGrammarException: could not execute query
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'dbname.User' doesn't exist

我的Hibernate配置

   <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost/dbname</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

    <mapping class="com.some.Pojo.User"/>
    <mapping class="com.some.Pojo.Location"/>
    <mapping class="com.some.Pojo.Country"/>
    <mapping class="com.some.Pojo.TrainingRequest"/>
    <mapping class="com.some.Pojo.Priority"/>
    <mapping class="com.some.Pojo.Quarter"/>
    <mapping class="com.some.Pojo.Training"/>
    <mapping class="com.some.Pojo.TrainingType"/>
    <mapping class="com.some.Pojo.Product"/>
    <mapping class="com.some.Pojo.Status"/> 
    <mapping class="com.some.Pojo.SortCategory"/>

JDBC属性

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.dialect=org.hibernate.dialect.MySQLDialect
jdbc.databaseurl=jdbc\:mysql\://localhost\:3306/dbname
jdbc.username=root
jdbc.password=root
jdbc.show_sql=true

Servlet的配置

      <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
    p:url="${jdbc.databaseurl}"
    p:username="${jdbc.username}" p:password="${jdbc.password}" />


    <!-- creating single instance of sessionfactory to be available throughout the application -->

<beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="configLocation">
    <beans:value>classpath:hibernate.cfg.xml</beans:value>
</beans:property>
<beans:property name="configurationClass">
    <beans:value>org.hibernate.cfg.AnnotationConfiguration</beans:value>
</beans:property>
<beans:property name="hibernateProperties">
    <beans:props>
        <beans:prop key="hibernate.dialect">${jdbc.dialect}</beans:prop>
        <beans:prop key="hibernate.show_sql">true</beans:prop>
    </beans:props>
</beans:property>
</beans:bean>

我错过了什么吗?我将它部署在带有Tomcat服务器的Ubuntu上,并将Mysql服务器部署为DB。

1 个答案:

答案 0 :(得分:3)

我可能遗漏了一些东西,但是这一行没有指出你的答案:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:表'dbname.User'不存在