以下是我的配置文件,用mysql的时候没问题,用sqlserver的时候就有了问题.<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"><!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration> <session-factory>
<!-- properties -->
<!--
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/NEWSDB?useUnicode=true&characterEncoding=utf8</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
-->
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:microsoft:sqlserver://localhost;database=NEWS</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="show_sql">true</property> <!-- mapping files -->
<mapping resource="org/woden/news/Cate.hbm.xml"/>
<mapping resource="org/woden/news/News.hbm.xml"/> </session-factory></hibernate-configuration>ps:程序我完全没改...sqlserver连接是成功的,因为我设置了show_sql,控制台能成功显示sql语句,而sql语句我拿到sqlserver中执行也是成功的...极度郁闷!高手帮忙...Hibernate: insert into CATE (NAME, DESCRIPTION, PARENT_ID) values (?, ?, ?) select scope_identity()
java.lang.Exception: Addition ExceptionAddition Exception是我DAO中add类抛出的错误...
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"><!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration> <session-factory>
<!-- properties -->
<!--
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/NEWSDB?useUnicode=true&characterEncoding=utf8</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
-->
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:microsoft:sqlserver://localhost;database=NEWS</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="connection.password"></property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="show_sql">true</property> <!-- mapping files -->
<mapping resource="org/woden/news/Cate.hbm.xml"/>
<mapping resource="org/woden/news/News.hbm.xml"/> </session-factory></hibernate-configuration>ps:程序我完全没改...sqlserver连接是成功的,因为我设置了show_sql,控制台能成功显示sql语句,而sql语句我拿到sqlserver中执行也是成功的...极度郁闷!高手帮忙...Hibernate: insert into CATE (NAME, DESCRIPTION, PARENT_ID) values (?, ?, ?) select scope_identity()
java.lang.Exception: Addition ExceptionAddition Exception是我DAO中add类抛出的错误...
还有在DAO中重抛出异常之前调用e.printStackTrace()
把信息给贴出来
org/woden/news/Cate.hbm.xml
org/woden/news/News.hbm.xml
不过sqlserver能执行的语句,hibernate报错确实挺奇怪
其实他们时一样的啊
有没有可能是你插入的数据过长数据库容纳不下啊
比如description还有select scope_identity()是什么dd?
org/woden/news/News.hbm.xml这两个是没问题的.因为我之前用mysql使用都正常...我DAO抛出的都是自定义的错误.