有一个使用Hibernate连接SqlServer的问题 应该不是数据库连接的问题,我感觉是你的配置文件有问题,'public_DocClass_info' 是什么?把这部分的配置和程序贴出来! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是数据库中的表名啊PublicDocClassInfo是类名,映射public_DocClass_info数据表名 把你的xml贴出来,应该是这里面的问题 <?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" ><hibernate-mapping><!-- Created by the Middlegen Hibernate plugin 2.1 http://boss.bekk.no/boss/middlegen/ http://www.hibernate.org/--><class name="oa.bean.PublicDocClassInfo" table="public_DocClass_info"> <meta attribute="class-description" inherit="false"> @hibernate.class table="public_DocClass_info" </meta> <id name="id" type="int" column="id" > <meta attribute="field-description"> @hibernate.id generator-class="assigned" type="int" column="id" </meta> <generator class="native" /> </id> <property name="fatherId" type="java.lang.Integer" column="fatherId" length="10" > <meta attribute="field-description"> @hibernate.property column="fatherId" length="10" </meta> </property> <property name="myName" type="java.lang.String" column="myName" length="50" > <meta attribute="field-description"> @hibernate.property column="myName" length="50" </meta> </property> <property name="styleCode" type="int" column="style_code" not-null="true" length="10" > <meta attribute="field-description"> @hibernate.property column="style_code" length="10" not-null="true" </meta> </property> <!-- Associations --></class></hibernate-mapping> 另外,还有个问题,我估计与此有关的.我估计此问题是否与Hibernate中dataSource一项相关,因为在用工具生成hbm文件时,我记得资料上说dataSource一项一定要如下配置(连接MSSqlServer时)==================================…… <property name="database.userid" value="sa"/> <property name="database.password" value="123"/> <property name="database.schema" value="dbo"/> <property name="database.catalog" value="oa"/>=================================于是我在Hibernate的实始化文件中dataSource一段加了如下两个属性================================= <property name="schema"> <value>dbo</value> </property> <property name="catalog"> <value>oa</value> </property>=================================结果,初始化时,出错提示说是这两个属性(dataSource)都是只读的,不让改。 <generator class="native" />你的数据库表,对这个字段有没有设置,自增! 关于使用hibernate,高分!! StringBuffer如何添加空格 分布式数据库的问题 各位大侠,救救我吧!!! JSON取值 数据导入 tomcat+servlet+userbean问题求解 oracle long字段 能不能用spring,不通过action直接和dao进行数据库操作? Weblogic 的console应用程序在哪个目录? 请问new出来的context在什么时候需要close?会不会由于某些原因没法被gc而导致内存泄漏? hibernate如何执行SQL语句?
PublicDocClassInfo是类名,映射public_DocClass_info数据表名
应该是这里面的问题
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" ><hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1 http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
--><class
name="oa.bean.PublicDocClassInfo"
table="public_DocClass_info"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="public_DocClass_info"
</meta> <id
name="id"
type="int"
column="id"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="int"
column="id"
</meta>
<generator class="native" />
</id> <property
name="fatherId"
type="java.lang.Integer"
column="fatherId"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="fatherId"
length="10"
</meta>
</property>
<property
name="myName"
type="java.lang.String"
column="myName"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="myName"
length="50"
</meta>
</property>
<property
name="styleCode"
type="int"
column="style_code"
not-null="true"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="style_code"
length="10"
not-null="true"
</meta>
</property> <!-- Associations -->
</class>
</hibernate-mapping>
我估计此问题是否与Hibernate中dataSource一项相关,因为在用工具生成hbm文件时,我记得资料上说dataSource一项一定要如下配置(连接MSSqlServer时)
==================================
……
<property name="database.userid" value="sa"/>
<property name="database.password" value="123"/>
<property name="database.schema" value="dbo"/>
<property name="database.catalog" value="oa"/>
=================================
于是我在Hibernate的实始化文件中dataSource一段加了如下两个属性
=================================
<property name="schema">
<value>dbo</value>
</property>
<property name="catalog">
<value>oa</value>
</property>
=================================
结果,初始化时,出错提示说是这两个属性(dataSource)都是只读的,不让改。