1. Connect to Database (1) Press, click View-----Select tool Windows----------Select Database and click
(2) Pop Up the Database window, click the plus sign------------Select the data source---------------Select the databases you want to add and click
(3) Pop up the datasources and Drivers window and fill in the circled box respectively. Host-----Write IP address database-------write the name user-------write an account password------write the password, you can click Test Connection, if the connection is successful, then test The right side of the connection button displays a word indicating that the connection was successful. When the connection is successful, click OK in the lower right corner.
(4) After clicking OK, the following results appear, and a database appears.
Two. Add JPA 1. Click File first to see project Structure
2. Click Modules and click on the + sign. I'm using the JPA here
Three. Generate Entity (1) Press, click View---------Select tool windows---------------------Select Persistence and click
(2) Click Persistence will appear persistence window, persistence below the database we connected, is the arrow pointing.
(3) Press, select and click the added database------------------Select Generate Persistence Mapping---------Select by database schema and click
(4) Click by Database Schema, pop up as window, fill in the circled part choose Data Source------------------------ Click on the lower right triangle to select a database package----------------------Select one of the packages in the project, the resulting entity will become a class file placed under that package the third part shows the table of the database, each table generates an entity, tick the table that wants to generate the entity, Then press OK in the lower right corner. This allows the entity to be generated.
Idea connection database automatically generates entity classes