锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线播放一区二区三区,99re6热只有精品免费观看,精品国产乱码久久久久久1区2匹http://www.aygfsteel.com/jx1984520/category/21041.html韜槸鑿╂彁鏍戯紝蹇冨鏄庨暅鍙幫紝鏃舵椂鍕ゆ媯鎷紝鍕夸嬌鏌撳皹鍩冦? 鑿╂彁鏈棤鏍戯紝鏄庨暅浜﹂潪鍙幫紝鏈潵鏃犱竴鐗╋紝浣曞鎯瑰皹鍩冦?/description>zh-cnSun, 22 Apr 2007 03:32:47 GMTSun, 22 Apr 2007 03:32:47 GMT60myeclipse涓媓ibernate鍒濇瀹炰緥http://www.aygfsteel.com/jx1984520/articles/106773.htmljavabrightjavabrightTue, 27 Mar 2007 13:55:00 GMThttp://www.aygfsteel.com/jx1984520/articles/106773.htmlhttp://www.aygfsteel.com/jx1984520/comments/106773.htmlhttp://www.aygfsteel.com/jx1984520/articles/106773.html#Feedback0http://www.aygfsteel.com/jx1984520/comments/commentRss/106773.htmlhttp://www.aygfsteel.com/jx1984520/services/trackbacks/106773.htmlmyeclipse涓媓ibernate鍒濇瀹炰緥

璇存槑錛氭湰渚嬮噰鐢╩yeclipse+sqlserver2000
 hibernate鐗堟湰涓?.0.
 鏁版嵁搴撻┍鍔ㄤ負錛歫tds-1.0.2銆?/p>

1銆傞厤緗甿yeclipse鐜錛坋clipse-SDK-3.1.1+myeclipse4.1.1GA_E3.1錛夈?br>2.閰嶇疆濂絪qlserver2000鏁版嵁搴擄細寤虹珛鏁版嵁搴擄細goto  . 琛?test_products

CREATE TABLE [dbo].[test_products] (
 [id] [int] IDENTITY (1, 1) NOT NULL ,
 [aotoid] [char] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [username] [char] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [price] [int] NULL ,
 [amount] [int] NULL
)
id涓鴻嚜鍔ㄧ紪鍙楓?/p>

3銆傛柊寤洪」鐩?-myeclipse--Web Project 銆傛湰渚嬩負錛歱rodcast
4. 鍙沖崟鍑籶rodcast錛屽姞鍏yeclipse鐨刪ibernate.騫跺湪姝ゅ伐紼嬩腑寤虹珛鏁版嵁榪炵粨銆?br>寤虹珛瀹屾垚鍚庯紝鍦╯rc涓嬭嚜鍔ㄧ敓鎴恏ibernate.cfg.xml錛屽唴瀹逛負錛?br><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
 <property name="connection.username">sa</property>
 <property name="connection.url">jdbc:jtds:sqlserver://192.168.1.88:1433;DatabaseName=goto</property>
 <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
 <property name="connection.password">hcsys</property>
 <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

</session-factory>

</hibernate-configuration>
5銆傚緩绔嬶細Product.java:
package test.hibernate;

import java.io.Serializable;

public class Product implements Serializable {

 private static final long serialVersionUID = 3858043967100350732L;
 private Integer id;
 private String aotoid;
 private String username;
 private Integer price;
 private Integer amount;

 public Integer getAmount() {
  return amount;
 }
 public void setAmount(Integer amount) {
  this.amount = amount;
 }
 public String getAotoid() {
  return aotoid;
 }
 public void setAotoid(String aotoid) {
  this.aotoid = aotoid;
 }
 public Integer getPrice() {
  return price;
 }
 public void setPrice(Integer price) {
  this.price = price;
 }
 public String getUsername() {
  return username;
 }
 public void setUsername(String username) {
  this.username = username;
 }
 public Integer getId() {
  return id;
 }
 public void setId(Integer id) {
  this.id = id;
 } 
}
6.寤虹珛InsertProduct.java
package test.hibernate;

import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.*;
import org.hibernate.classic.Session;

public class InsertProduct {

 public static void main(String[] args) {
  
  SessionFactory sf = new Configuration().configure()
       .buildSessionFactory();
  Session session = sf.openSession();
  Transaction tx = session.beginTransaction();
  
  Product p  = new Product();
  p.setAotoid("1");
  p.setUsername("zhang");
  p.setAmount(new Integer(10));
  p.setPrice(new Integer(10));
  System.out.println(p+"_______________1");
  try{
   session.save(p);
   tx.commit();
   session.close();
   System.out.println(p+"_______________2");
  }catch(Exception ex){
   ex.printStackTrace();
  }  
 }
}
7.鍦╰est.hibernate鍖呬笅寤虹珛:Product.hbm.xml.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "
   
<hibernate-mapping package="test.hibernate">
 <class table="test_products" name="Product">
  <!--鑷姩緙栧彿-->
  <id name="id" type="int" column="id" unsaved-value="0">
         <generator class="identity"/>
  </id>

  <property name="aotoid" column="aotoid" type="string" length="50"/> 
  <property name="username" column="username" type="string" length="50"/>    
  <property name="price" column="price" type="int"/>
  <property name="amount" column="amount" type="int"/>
 
 </class>

</hibernate-mapping>

8.鎵撳紑hibernate.cfg.xml.鍔犲叆錛?br> <mapping resource="hibernate.cfg.xml" />
 <mapping resource="test/hibernate/Product.hbm.xml" />
褰㈡垚瀹屾暣鐨刢onfig:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
 <property name="connection.username">sa</property>
 <property name="connection.url">jdbc:jtds:sqlserver://192.168.1.88:1433;DatabaseName=goto</property>
 <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
 <property name="connection.password">hcsys</property>
 <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
 <mapping resource="hibernate.cfg.xml" />
 <mapping resource="test/hibernate/Product.hbm.xml" />

</session-factory>

</hibernate-configuration>
9.榪愯InsertProduct.java灝卞彲浠ョ湅鍒版暟鎹簱goto琛╰est_products涓鍔犱簡涓鏉¤褰曘?br> 



]]>
主站蜘蛛池模板: 华亭县| 丰都县| 甘孜县| 曲麻莱县| 黄平县| 昌平区| 张掖市| 桦甸市| 水富县| 广灵县| 上思县| 塔城市| 金坛市| 武冈市| 秀山| 湟中县| 合作市| 武清区| 左权县| 五台县| 渑池县| 江西省| 安徽省| 阿坝| 色达县| 北安市| 西和县| 鄱阳县| 武隆县| 当雄县| 郸城县| 南京市| 凭祥市| 寻乌县| 精河县| 苏尼特右旗| 奉新县| 息烽县| 错那县| 平昌县| 高陵县|