Using the idea to operate:
1) Create a maven project
Select maven repository, choose their own maven installation location, user settings file is installed in the conf folder settings.xml file maven. local repository is a local warehouse, set up after clicking next
Setting the project name
2) Add Dependency
Add the pom.xml dependencies
3) JDBC connector
Not recommended to set write code so creating db.properties in resources
Here mysql8.0 or later driver is com.mysql.cj.jdbc.Driver. You will get an error during testing, because the version, add to the url? serverTimezone = GMT
Creating JDBCUtil Tools
DB connection needs to release resources
4) Test: Create JDBCUtilTest class in the Test Pack
operation result:
Access to the database on behalf of success.
5) create a database, insert three data
6) Dao layer:
Create an entity class, calling the set and get methods
Creating Dao Interface
Creating Dao interface class
Test, create StudentDaoImplTest in the Test package:
Queries to the data, success.
Add data, add the interface class:
daoimpl override method
carry out testing
No error, the database also added data