If you are building a Java application with Hibernate and need to connect to a , your first step is creating a hibernate.cfg.xml file. This central configuration file tells Hibernate how to connect to your database, which driver to use, and how to map your Java objects to database tables. Sample hibernate.cfg.xml for MySQL 8+
For modern applications using , you must use the updated JDBC driver and dialect. Copy the template below and save it as hibernate.cfg.xml in your project's src/main/resources folder: