目标:将Student实体对象加入数据库1、首先需要下载三个东西:hibernate,slf4j,mysql。2、分别取他们的包导入新建的项目中,我这里的版本是:hibernate-release-5.2.10里面lib目录下的requir
目标:将Student实体对象加入数据库
1、首先需要下载三个东西:hibernate,slf4j,mysql。
2、分别取他们的包导入新建的项目中,我这里的版本是:hibernate-release-5.2.10里面lib目录下的required中的全部文件 slf4j-1.7.25下的受slf4j-nop-1.7.25.jar Mysql的mysql-connector-java-5.1.42-bin.jar
3、在src下配置hibernate.cfg.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><!-- Database connection settings --><property name="connection.driver_class">com.mysql.jdbc.Driver</property><property name="connection.url">jdbc:mysql://localhost/text02</property><property name="connection.username">root</property><property name="connection.passWord">6530033197</property><!-- JDBC connection pool (use the built-in) --><!--<property name="connection.pool_size">1</property>--><!-- SQL dialect --><property name="dialect">org.hibernate.dialect.MySQLDialect</property><!-- Enable Hibernate's automatic session context management --><!-- <property name="current_session_context_class">thread</property> --><!-- Disable the second-level cache --><property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property><!-- Echo all executed SQL to stdout --><property name="show_sql">true</property><!-- Drop and re-create the database schema on startup --><!--<property name="hbm2ddl.auto">update</property>--><mapping resource="student/Student.hbm.xml"/></session-factory></hibernate-configuration>
--结束END--
本文标题: hibernate5.2的基本配置方法(详解)
本文链接: https://lsjlt.com/news/225649.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0