---
title: "org.hibernate.exception.SQLGrammarException"
author: "SnailWong"
date: "2010-01-08T09:24:04Z"
tags: ["Bean", "Hibernate", "MySQL", "SQL Server", "数据结构"]
categories: ["企业架构"]
slug: "org-hibernate-exception-sqlgrammarexception"
draft: false
lastmod: "2010-01-08T09:24:04Z"
id: 565490
url: "https://snailwong.iteye.com/blog/565490"
---

一般这个问题是由于用了工具自动生成\*.hbm.xml文件 而发生的错误,一开始你的程序是好的,但是在你换了台机器,访问的数据库有变化时(也许用到里面的表都没有变动),可能就会出现org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update的问题解决办法是把\*.hbm.xml文件的  schema=" " 改为现在对应的用户&lt;hibernate-mapping&gt;  
    &lt;class name="com.ecai.bean" table="Member" schema="web" catalog="ecai"&gt;  
        &lt;id name="rid" column="RID"  type="long"&gt;  
            &lt;generator class="increment" /&gt;这样就能够连接上你的数据库，但是这样对有的程序来说是可以的，有的就会报 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &apos;.member member0_ where member0\_.UserName=&apos;ad&apos; and member0\_.UserPass=&apos;7815696ecbf&apos; 类似于这样的错误，这个是由于你的数据库表的结构和你换到另一台机子上的数据库表结构不一样，一定要对应好，就连数据库表名的大小写都要对应好。

本文来自CSDN博客，转载请标明出处：[http://blog.csdn.net/chenjieli/archive/2009/05/30/4226125.aspx](http://blog.csdn.net/chenjieli/archive/2009/05/30/4226125.aspx)