yr512656630 2009-11-12 16:41
浏览 260
已采纳

高手帮下:SSH整合mysql问题

之前数据库是SQL2000的,用SSH整合后很完美,一点错误都没有,但因需要,将数据库的版本换成mysql后,错误来了

:cry: 我就是将SPRING的配置文件修改了数据源,本以为这样就完了,确实大家想的改下驱动和URL就OK了,可不知道哪里出错了,任何增删改查都不能用了,错误如下:

Hibernate: select news0_.id as id, news0_.typeId as typeId4_, news0_.title as title4_, news0_.content as content4_, news0_.newtime as newtime4_, news0_.auth as auth4_, news0_.toup as toup4_ from company.dbo.News news0_ where typeId=1 limit ?

2009-11-12 16:25:08,750 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 1064, SQLState: 42000

2009-11-12 16:25:08,750 ERROR [org.hibernate.util.JDBCExceptionReporter] - 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 '.News news0_ where typeId=1 limit 10' at line 1
org.hibernate.exception.SQLGrammarException: could not execute query

请大家帮下忙,我怀疑是数据库的版本问题,数据库是MySQL-server-community-5.0.87-0.rhel3.i386.rpm在linux的。。。。坐等
[b]问题补充:[/b]
是支持的,HQL这个可以用当为sql2000的时候是top,mysql是limit,我在DAO的文件中用了

Query query = session.createQuery(hql);
query.setFirstResult(0);
query.setMaxResults(10);

这个不影响查询前10条记录,呵呵,不是这的问题,我确定
[b]问题补充:[/b]
大家很,很感激你们的帮助,这是我的程序代码
[code="java"]
/*这是hirbernate和Spring整合后的配置文件*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


class="org.apache.commons.dbcp.BasicDataSource">
value="com.mysql.jdbc.Driver">

value="jdbc:mysql://127.0.0.1:3306/company">




class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">






org.hibernate.dialect.MySQLDialect

true
true




pojo/Admin.hbm.xml
pojo/CateType.hbm.xml
pojo/FishList.hbm.xml
pojo/NewsType.hbm.xml
pojo/News.hbm.xml

[/code]

[code="java"]
/**这是我pojo的映射文件,以前直接是sql2000映射后的,我现在直接拿来用
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
























        <!-- 一个消息有一个类别 -->
        <many-to-one name="newsType" column="typeId" class="pojo.NewsType" lazy="false"></many-to-one>
</class>

[/code]
[b]问题补充:[/b]
哦,还有个问题,mysql中能使用nvrchar(4000)这个吗

  • 写回答

7条回答 默认 最新

  • satanest 2009-11-12 18:42
    关注

    [quote]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 '.News news0_ where typeId=1 limit 10' at line 1 [/quote]
    [quote]ews0_.toup as toup4_ from company.dbo.News news0_ where typeId=1 limit ? [/quote]
    根据异常信息和生成的sql语句判断,company.dbo.News有问题
    mysql里面是没有这样的名字空间的,看看你的映射文件,可能是table映射写错了。
    正常情况下应该是company.News

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算