Example of the JPA and Mysql Database integration
In this example, a database ("example_mysql") is created based on Msql
The fundamental classes are
- Student
- StudentInterface
- DataLoader
The Student class is in charge of representing the model
The StudentInterface is in charge of create the JPA repository
The DataLoader class is in charge of populating the BD
The configuration of the connection with the mysql db is defined in the appliction properties file
- spring.datasource.url=jdbc:mysql://localhost:3306/mysql_example?serverTimezone=UTC
- spring.datasource.username=root
- spring.datasource.password=
- spring.jpa.hibernate.ddl-auto=create-drop
- spring.jpa.show-sql=true
The final result is the creation and insertion of data in the student table