MySQL is one of the most popular open-source database systems available today. Let us create hibernate.cfg.xml configuration file and place it in the root of your application's classpath. You would have to make sure that you have testdb database available in your MySQL database and you have a usertest available to access the database.
The XML configuration file must conform to the Hibernate 3 Configuration DTD, which is available from http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <propertyname="hibernate.dialect"> < org.hibernate.dialect.MySQLDialect </property> <propertyname="hibernate.connection.driver_class"> < com.mysql.jdbc.Driver </property> <!-- Assume test is the database name --> <propertyname="hibernate.connection.url"> jdbc:mysql://localhost/test </property> <propertyname="hibernate.connection.username"> root </property> <propertyname="hibernate.connection.password"> root123 </property> <!-- List of XML mapping files --> <mappingresource="Employee.hbm.xml"/> </session-factory> </hibernate-configuration> The above configuration file includes
|