entity class PackageCom.tao.pojo; Public classStudent {
PrivateString ID; PrivateString name; PrivateString Pass; PublicStudent () {Super(); } PublicStudent (string name, String pass) {Super(); This. Name =name; This. pass =Pass; } PublicStudent (string ID, string name, String pass) {Super(); This. ID =ID; This. Name =name; This. pass =Pass; } PublicString getId () {returnID; } Public voidsetId (String id) { This. ID =ID; } PublicString GetName () {returnname; } Public voidsetName (String name) { This. Name =name; } PublicString Getpass () {returnPass; } Public voidSetPass (String pass) { This. pass =Pass; } @Override PublicString toString () {return"Student [id=" + ID + ", name=" + name + ", pass=" + Pass + "]"; }} Map File<?xml version= "1.0"? ><! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en" "http://hibernate.sourceforge.net/ Hibernate-mapping-3.0.dtd "><!--Generated 2018-3-1 14:18:27 by Hibernate Tools 3.5.0.Final-->< Hibernate-mapping> <className= "Com.tao.pojo.Student" table= "Student" > <id name= "id" type= "java.lang.String" > <column Name= "ID"/> <generatorclass= "uuid"/> </id> <property name= "name" type= "java.lang.String" > <column name= "N AME "/> </property> <property name=" pass "type=" java.lang.String "> <column name = "PASS"/> </property> </class>configuration file<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE hibernate-Configuration Public"-//hibernate/hibernate Configuration DTD 3.0//en" "Http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" & gt;//localhost:3306/test0228_002</property><property name= "Hibernate.connection.username" >root</property> <property name= "Hibernate.dialect" & gt;org.hibernate.dialect.mysqldialect</property> <property name= "Show_sql" >true</property> <property name= "Format_sql" >true</property> <property name= "Hbm2ddl.auto" >update</property> <mapping resource= " Com/tao/pojo/student.hbm.xml "/> </session-factory>Test Packagecom.tao.test;Importorg.hibernate.Session;Importorg.hibernate.SessionFactory;Importorg.hibernate.cfg.Configuration;ImportOrg.hibernate.dialect.MySQL5Dialect; Public classTestmain {//Create a table with the Hibernate framework Public Static voidMain (string[] args) {Configuration Configure=NewConfiguration (). Configure ("Hibernate.cfg.xml"); Sessionfactory Factory=configure.buildsessionfactory (); Session Session=factory.opensession (); Session.begintransaction (); Session.gettransaction (). commit (); Session.close (); Factory.close (); }} Use the program to generate the table, if the report has this error caused By:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL Syntax Check the manual, corresponds to your MySQL server version forThe right syntax to use near ' Type=myisam ' at line 6The solution changes the database dialect to<property name= "Hibernate.dialect" >org.hibernate.dialect.MySQL5Dialect</property>
MySQL Database creation table Error solution