Hibernate简单的框架的基本配置??
各位兄弟姐妹,我在Hibernate框架配置文件的时候,不知道是数据哪里出现问题,导致无法运行,
下面是我写的代码以及配置文件
基本类文件:
package com.wish.model;
public class Userlogin {
private int id;
private String name;
private String password;
public Userlogin() {
super();
// TODO Auto-generated constructor stub
}
public Userlogin(int id, String name, String password) {
super();
this.id = id;
this.name = name;
this.password = password;
}
public Userlogin(String name, String password) {
super();
this.name = name;
this.password = password;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
*****************************************************
映射的 Userlogin.hbm.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="myeclipse.connection.profile">oracledriver</property>
<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:ORCL</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<mapping resource="com/wish/model/Userlogin.hbm.xml"/>
</session-factory>
</hibernate-configuration>
*********************************************************
配置 hibernate.cfg.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.wish.model.Userlogin" table="userh">
<id name="id" column="Id" >
<generator class="sequence">
<param name="sequence">xulie</param>
</generator>
</id>
<property name="name" column="Username"></property>
<property name="password" column="Password"></property>
</class>
</hibernate-mapping>
*********************************************
测试*******java*******代码
package com.wish.model;
import
org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class TextSave {
public static void main(String[] args){
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");