第一个Hibernate 程序终于测试通过了
2007-11-20 11:36
423 查看
java 好多地方都要自己配置,习惯了 vs 的东西,真是不适应。
CurUser.java
package test;
CurUser.hbm.xml
<?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">
<hibernate-mapping>
<class name="test.CurUser" table="test">
<id name="Curid" type="string" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property name="Name" type="string"/>
</class>
</hibernate-mapping>
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost/first
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<mapping resource="test/CurUser.hbm.xml" />
</session-factory>
</hibernate-configuration>
测试页面
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
</body>
</html>
create database if not exists `first`;
USE `first`;
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`Curid` varchar(50) collate utf8_unicode_ci default NULL,
`name` varchar(50) collate utf8_unicode_ci default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CurUser.java
package test;
CurUser.hbm.xml
<?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">
<hibernate-mapping>
<class name="test.CurUser" table="test">
<id name="Curid" type="string" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property name="Name" type="string"/>
</class>
</hibernate-mapping>
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost/first
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<mapping resource="test/CurUser.hbm.xml" />
</session-factory>
</hibernate-configuration>
测试页面
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
</body>
</html>
create database if not exists `first`;
USE `first`;
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`Curid` varchar(50) collate utf8_unicode_ci default NULL,
`name` varchar(50) collate utf8_unicode_ci default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
相关文章推荐
- 第一个hibernate程序
- 配置IIS--通过多台设备之间建立局域网--测试Application_onStart事件计算当前网站程序在线人数
- Hibernate通过SQL查询常量时只能返回第一个字符的解决方法
- HIbernate学习笔记(一) 了解hibernate并搭建环境建立第一个hello world程序
- 创建第一个hibernate程序
- 第一个Hibernate程序――错误整理
- 攻城狮在路上(壹) Hibernate(二)--- 第一个hibernate程序
- 第一个Hibernate程序
- Hibernate第一个程序
- Tiny4412第一个qtopia2.2.0测试程序mycalc
- 非常不错的flash采集程序测试通过
- Android LBS App:春节在家无聊昨天忙活了一天,终于无师自学,开发了俺的第一个Android 程序
- [程序代写推荐]spring Scurity终于测试OK了,复杂的功能还待深入研究!发布出来一起探讨吧!
- Hibernate通过SQL查询常量时只能返回第一个字符的解决方法
- PhoneGap(windows)环境下的安装和第一个测试程序
- 利用msfvenom生成***程序,在win7 sp1测试通过
- Hibernate---第一个helloworld程序 (XML版本, annotation版本)
- 编写你的第一个Hibernate程序 (在Hibernate中使用oracle的sequence产生主键 )
- 【糟糕的代码】Android的第一个程序:简单的皮肤更换测试
- Hibernate通过SQL查询常量时只能返回第一个字符的解决方法