ÔÚʹÓÃHibernateÅäÖÃMySqlµÄʱºò£¬¹Ù·½¸ø³öµÄʾÀýÊÇ£¬ÊÇÕâôÅäÖõģº
±í1
<propertyname="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> |
¶øÔÚÅäÖõÄʱºò£¬ÎÒÃÇÍùÍù»¹»á¸øHibernateÌí¼ÓÒ»¸ö¸üвßÂÔ£º
±í2
<propertyname="hibernate.hbm2ddl.auto">update</property> |
ÕâÑùÒ»À´£¬ÔÚÔËÐгÌÐòµÄʱºò£¬¾ÍÓпÉÄÜ»áÔì³ÉÕâÑùµÄÒ»¸öÒì³£ÐÅÏ¢£º
±í3
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 7 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 36 more |
¸ù¾ÝÌáʾºÜÏÔÈ»µÃÖª£ºÕâÊÇMySQLµÄ°æ±¾ÎÊÌâµ¼ÖµÄÎÊÌâ¡£
ʵ¼ÊÉÏ£¬ÔÚMySQL5.0ÒÔÇ°£¬type=InnoDBÊÇÓÐЧµÄSQLÓï¾ä£¬¶øÏÖÔÚ£¬ÎÒÃÇÓõĴó¶à¶¼ÊÇMySql5.6¡¢MySQL5.7°æ±¾£¬type=InnoDB²»ÔÙÓÐЧÁË¡£
½â¾ö°ì·¨¾ÍÊÇÐÞ¸Ähibernate.cfg.xmlÖеÄdialectÊôÐÔ£¬½«
±í4
<propertyname="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> |
ÐÞ¸ÄΪ£º
±í5
<propertyname="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> |
ÕâÊÇHibernateÖÐÅäÖÃMySqlËùÐèҪעÒâµÄÒ»µã£¡£¡£¡
END£¡£¡£¡