• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

hebernate与mysql调整

mysql 搞代码 4年前 (2022-01-09) 12次浏览 已收录 0个评论

hebernate与mysql整合 1.下载mysql, 如何安装 2.开始在myeclipse 整合hebernate hebernate 需要的一些包: 配置文件:(Mysql 已开启远程连接) ?xml version=’1.0′ encoding=’UTF-8′?!DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Config

hebernate与mysql整合

1.下载mysql,

如何安装

2.开始在myeclipse 整合hebernate

hebernate 需要的一些包:

配置文件:(Mysql 已开启远程连接)

<?xml version='1.0' encoding='UTF-8'?>	root	jdbc:mysql://192.168.1.135:3306/SolarWorkFlowDb?useUnicode=true&characterEncoding=utf8	org.hibernate.dialect.MySQLDialect	mysqll	solar	com.mysql.jdbc.Driver	true	true	true	org.hibernate.cache.本文来源gaodaimacom搞#^代%!码&网(EhCacheProvider    

配置文件2

<?xml version="1.0" encoding="utf-8"?>            测试数据                                                                                                                                

实体类:

package test;public class Person {	private int ID ;	private String FULL_NAME;	private String LAST_NAME;		public Person(){}	public Person(int iD, String fULLNAME, String lASTNAME) {		super();		ID = iD;		FULL_NAME = fULLNAME;		LAST_NAME = lASTNAME;	}	public int getID() {		return ID;	}	public void setID(int iD) {		ID = iD;	}	public String getFULL_NAME() {		return FULL_NAME;	}	public void setFULL_NAME(String fULLNAME) {		FULL_NAME = fULLNAME;	}	public String getLAST_NAME() {		return LAST_NAME;	}	public void setLAST_NAME(String lASTNAME) {		LAST_NAME = lASTNAME;	}    		}

测试类

package test;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;public class TestPro {	/**	 * @param args	 */	public static void main(String[] args) {		// TODO Auto-generated method stub		Person p = new Person();			p.setFULL_NAME("Tom");		p.setLAST_NAME("LEE");		Configuration cfg = new Configuration();		SessionFactory sf = cfg.configure().buildSessionFactory();				Session session = sf.openSession();		session.beginTransaction();		session.save(p);		session.getTransaction().commit();		session.close();		sf.close();	}}

表结构:

测试结果:

资料:点击打开链接


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:hebernate与mysql调整

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址