introduction
What we are doing is an introductory practice, so we can just create a table in the database to verify the login!
Create database
We first create the database sshLogin, and inside the database, create the table User!
Associate with the database through idea
Enter the user, password, select the database source with the database
configuration Hibernate
, and create and create a new folder to put our entity classes!
Select the data table and
click OK
Results
Let's test the table
We insert a piece of data in the database
Configure Hibernate files
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!--加载数据库驱动-->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/sshLogin?serverTimezone=UTC</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<!--指定数据库方言-->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- DB schema will be updated if needed -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!--在控制台显示SQL语句-->
<property name="show_sql">true</property>
<!--将SQL脚本中语句格式化在输出-->
<property name="hibernate.format_sql">true</property>
<!--罗列所有的持久化类-->
<mapping class="com.Entity.UserEntity"/>
</session-factory>
</hibernate-configuration>