Create an SSH project in eclipse and use hibernate to create the corresponding table of the object in the database based on the domain object.
After the project is started, it always reports that the table where the insertion error is located does not exist. I have found many ways to solve this problem on the Internet. After a few days of tossing, I finally got it ready (it was easy to use MySQL)
I hope this will help you. For more information, see the source. Thank you!
The procedure is as follows:
// Start a configuration instance using the default hibernate. cfg. xml
Configuration conf = new configuration ();
Conf. Configure ("/hibernate. cfg. xml ");
Schemaexport dbexport = new schemaexport (CONF );
Dbexport. Create (True, true );
// Create a sessionfactory instance from the configuration instance
Sessionfactory = Conf. buildsessionfactory ();
Hibernate. cfg. xml:
<! -- Specify database Dialect -->
<Property name = "dialect"> org. hibernate. dialect. mysql5innodbdialect </property>
<! -- Automatically create a database as needed -->
<Property name = "hbm2ddl. Auto"> Update </property>
Create a database in eclipse
Database connection information