用Properties文件配Hibernate
来源:互联网 发布:ape转换wav软件 编辑:程序博客网 时间:2024/06/05 00:30
根目录下的hibernate.properties
hibernate.dialect=org.hibernate.dialect.Oracle10gDialectcurrent_session_context_class=threadhibernate.connection.url=jdbc:oracle:thin:localhost:1521:orclhibernate.connection.username=sjhibernate.connection.password=123456hibernate.connection.driver_class=oracle.jdbc.driver.OracleDrivershow_sql=truehbm2ddl.auto=updatehibernate.connection.pool_size=1cache.provider_class=org.hibernate.cache.NoCacheProvider
测试的Java类
package configuration;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.util.Properties;import hibernate.Person;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;public class ConfigurationTest {public static void main(String[] args) {try {Properties properties = new Properties();File file = new File("E:/Workspace/hhh/src/hibernate.properties");FileInputStream stream = new FileInputStream(file);properties.load(stream);Configuration cfg = new Configuration().addClass(hibernate.DocumentType.class).addClass(hibernate.Person.class).setProperties(properties);SessionFactory sessions = cfg.buildSessionFactory();Session session = sessions.openSession();session.beginTransaction();Person person = (Person)session.load(Person.class, new Long(1));person.getEmails().add("wow@sina.com");session.getTransaction().commit();session.close();System.out.println("结束");} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}}
- 用Properties文件配Hibernate
- 详解Hibernate.properties文件
- Hibernate log4j.properties文件内容
- MySQL连接Hibernate配置properties文件内容
- hibernate.properties文件配置属性归纳
- hibernate.properties
- Hibernate properties
- hibernate.properties
- hibernate.properties
- hibernate.properties
- spring与hibernate整合-使用properties文件分离数据库连接设置
- Hibernate从Java属性文件(properties)读取配置信息
- spring与hibernate整合-使用properties文件分离数据库连接设置
- 用Properties补充hibernate.cfg.xml配置
- 用Properties补充hibernate.cfg.xml配置
- 用java读取properties文件
- Properties读取properties文件
- Properties 读取 Properties文件
- 【树状数组 + 简单题】杭电 hdu 1166 敌兵布阵
- C# 播放视频
- 单例模式(Singleton)
- java练手题之六IO
- 02_简易评分系统(DOS界面)(小钱版)[2011-08-01]
- 用Properties文件配Hibernate
- php常用函数库
- 原码、反码和补码
- 很有哲理的文章
- jdbc连接sql server 2008异常,jdbc连接oracle10g也出现这个异常
- 递归的缺点,如何解决
- 利用jdbc连接sqlserver2008(打开用户,配置远程登录)
- 03_通讯录小项目设计DOS版V1.0(小钱版)[2011-09-18]
- 将字符串中的字符'*'移到串的前部分