Hibernate.cfg.xml 详解
来源:互联网 发布:手机驱鼠软件 编辑:程序博客网 时间:2024/05/29 18:50
的文件,没有进行说明。
1 Hibernate.cfg.xml 的内容
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class" >com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/testdb</property>
<property name="hibernate.connection.username">mysql</property>
<property name="hibernate.connection.password">mysql_2016</property>
<property name="hibernate.connection.pool_size">5</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="connection.useSSL">false</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
</session-factory>
</hibernate-configuration>
2 Hibernate.cfg.xml 属性解释
从名字,可以清楚的知道这是一个Hibernate配置文件。
这个配置文件中,主要是设置session-factory的属性。
hibernate.dialect是方言, 主要用于描述数据库数据类型和JAVA数据类型之间的映射关系
hibernate.connection.driver_class是驱动,定义通过何种驱动连接数据库。由于我们需要连接的是MySQL数据库,所以使用mySQL的驱动
这也是在Hibernate 连接本地MySQL 服务器 加入“ compile 'mysql:mysql-connector-java:6.0.4' ” 的原因。
hibernate.connection.url, 指定数据库的地址。 //localhost:3306/是指本机MySQL服务器的监听地址,testdb是数据库名称。
hibernate.connection.username,登录时的用户名。
hibernate.connection.password,登陆密码。
hibernate.connection.pool_size,最大连接数。
hibernate.hbm2ddl.auto,自动创建表。
以上属性配置正确,就能通过Hibernate 连接本地MySQL 服务器 第5步中的代码 生成session-factory。
添加Entity类到配置文件
<mapping class="Donation" /> Donation是类名称,需要添加全路径。
- Hibernate.cfg.xml 详解
- Hibernate.cfg.xml详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml 配置 详解
- hibernate.cfg.xml文件详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml文件详解
- hibernate.cfg.xml配置详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml文件详解
- hibernate.cfg.xml配置详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml文件详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml配置文件详解
- hibernate hibernate.cfg.xml各种属性详解
- 【Hibernate】Hibernate.cfg.xml配置文件详解
- codeforces 713C
- 【JZOJ4805】【NOIP2016提高A组模拟9.28】跟踪
- overridePendingTransition的简介
- hive加载json格式文件的方法
- Java中的类加载机制
- Hibernate.cfg.xml 详解
- linux 组调度浅析
- Mac上安装nginx
- Android基础之 EditText运用
- structs2+spring+mybatis 配置log4j
- java的jvm
- popupWindow使用返回为null
- 树状数组求区间最值
- 机器学习