使用以下方言创建表格时出现以下错误
" org.hibernate.dialect.MySQLInnoDBDialect"
Hibernate:create table user(id integer not null,name varchar(100),primary key(id))type = InnoDB
org.hibernate.tool.schema.spi.CommandAcceptanceException:通过JDBC语句执行DDL时出错 在org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) 在org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) 在org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:277) 在org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71) 在org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207) 在org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) 在org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) 在org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) 在org.hibernate.internal.SessionFactoryImpl。(SessionFactoryImpl.java:313) 在org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452) 在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710) 在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) 在com.adeptia.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:13) 在com.adeptia.hibernate.HibernateUtil。(HibernateUtil.java:8) 在com.adeptia.MainClass.returnHello(MainClass.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory $ 1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher $ 1.run(AbstractJavaResourceMethodDispatcher.java:143) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:160) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider $ TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:203) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:97) 在org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) 在org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) 在org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) 在org.glassfish.jersey.server.ServerRuntime $ 2.run(ServerRuntime.java:303) 在org.glassfish.jersey.internal.Errors $ 1.call(Errors.java:271) 在org.glassfish.jersey.internal.Errors $ 1.call(Errors.java:267) 在org.glassfish.jersey.internal.Errors.process(Errors.java:315) 在org.glassfish.jersey.internal.Errors.process(Errors.java:297) 在org.glassfish.jersey.internal.Errors.process(Errors.java:267) 在org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) 在org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286) 在org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1072) 在org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:399) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) 在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074) at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(未知来源) 引起:java.sql.SQLSyntaxErrorException:您的SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在' type = InnoDB'附近使用正确的语法。在第1行 在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:112) 在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) 在com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:116) 在com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:958) 在com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:808) 在org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ......还有56个
答案 0 :(得分:6)
如果您使用的MySQL版本大于5.0,请使用以下任何一种方言:
org.hibernate.dialect.MySQL5Dialect
org.hibernate.dialect.MySQL55Dialect
org.hibernate.dialect.MySQL57Dialect