2

嗨,我在 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

我的休眠配置

   <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>

我错过了什么吗?我将它部署在 Ubuntu 上,使用 Tomcat 服务器和 Mysql 服务器作为数据库。

4

1 回答 1

3

我可能遗漏了一些东西,但这条线没有给你指出答案:

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

于 2013-07-09T22:14:11.770 回答