title: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
body: <p>I am a novice in hibernate world and facing,</p>
  
  <pre><code>WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
  </code></pre>
  
  <p>exception while I run my stand-alone programe in hibernate 5.2.9 version. But in hibernate 4 version all my code runs well. I looked for many questions and solve but not working answer i got.</p>
  
  <blockquote>
    <p>Configuration file</p>
  </blockquote>
  
  <pre><code>hibernate.cfg.xml
  
      &lt;hibernate-configuration&gt;
        &lt;session-factory&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/test&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;admin&lt;/property&gt;
          &lt;property name="hibernate.connection.pool_size"&gt;20&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
          &lt;mapping class="com.test.hibernate14417.MyTable"&gt;&lt;/mapping&gt;
        &lt;/session-factory&gt;
      &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <blockquote>
    <p>Pom.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.test&lt;/groupId&gt;
      &lt;artifactId&gt;Hibernate14417&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;repositories&gt;
      &lt;/repositories&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;5.2.9.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-jpa-2.1-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.0.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;4.3.1.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sourceforge.jtds&lt;/groupId&gt;
              &lt;artifactId&gt;jtds&lt;/artifactId&gt;
              &lt;version&gt;1.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;3.1.11&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  
  <blockquote>
    <p>Utility file</p>
  </blockquote>
  
  <pre><code>package com.test.hibernate14417;
  
  import org.hibernate.SessionFactory;
  import org.hibernate.boot.Metadata;
  import org.hibernate.boot.MetadataSources;
  import org.hibernate.boot.registry.StandardServiceRegistry;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.service.ServiceRegistry;
  
  
  public class ExecuteUtil {
      private static final SessionFactory SESSION_FACTORY=buildSessionFactory();
  
      private static SessionFactory buildSessionFactory() {
          try {
              ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
                      .configure("hibernate.cfg.xml").build();
  
              Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();
  
              return metadata.getSessionFactoryBuilder().build();
  
          } catch (Throwable ex) {
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
  
      }
  
      public static SessionFactory getSESSION_FACTORY() {
          return SESSION_FACTORY;
      }
  
      public static void shutdown(){
          getSESSION_FACTORY().close();
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>Entity file</p>
  </blockquote>
  
  <pre><code>package com.test.hibernate14417;
  
  import java.io.Serializable;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  
  
  
  @Entity
  public class MyTable implements Serializable {
  
      @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
  
      private String name;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  
  
  }
  </code></pre>
  
  <blockquote>
    <p>Main method</p>
  </blockquote>
  
  <pre><code>package com.test.hibernate14417;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  
  
  public class Main {
      public static void main(String[] args) {
  
          MyTable mt=new MyTable();
          mt.setName("Man");
  
          SessionFactory sessionFactory=ExecuteUtil.getSESSION_FACTORY();
  
          Session session=sessionFactory.getCurrentSession();
  
  
          try {
            session.getTransaction().begin();
  
            session.save(mt);
  
            session.getTransaction().commit();
  
             session.close();
             sessionFactory.close();
  
          } catch (Exception e) {
              System.out.println(e.getStackTrace());
              session.getTransaction().rollback();
          }
  
  
      }
  </code></pre>
  
  <blockquote>
    <p>Console </p>
  </blockquote>
  
  <pre><code>cd D:\Netbeans\Hibernate14417; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_121" cmd /c "\"\"C:\\Program Files\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-classpath %classpath com.test.hibernate14417.Main\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_121\\bin\\java.exe\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
  Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
  Scanning for projects...
  
  ------------------------------------------------------------------------
  Building Hibernate14417 1.0-SNAPSHOT
  ------------------------------------------------------------------------
  
  --- exec-maven-plugin:1.2.1:exec (default-cli) @ Hibernate14417 ---
  Apr 14, 2017 10:41:51 AM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.2.9.Final}
  Apr 14, 2017 10:41:51 AM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  Apr 14, 2017 10:41:53 AM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
  WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
  Apr 14, 2017 10:41:54 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  Apr 14, 2017 10:41:54 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  Apr 14, 2017 10:41:54 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/test]
  Apr 14, 2017 10:41:54 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001001: Connection properties: {user=root, password=****}
  Apr 14, 2017 10:41:54 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001003: Autocommit mode: false
  Apr 14, 2017 10:41:54 AM org.hibernate.engine.jdbc.connections.internal.PooledConnections &lt;init&gt;
  INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
  Apr 14, 2017 10:41:55 AM org.hibernate.dialect.Dialect &lt;init&gt;
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
  Apr 14, 2017 10:41:55 AM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
  INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
  Hibernate: drop table if exists hibernate_sequence
  Apr 14, 2017 10:41:58 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
  INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@24111ef1] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
  Hibernate: drop table if exists MyTable
  Hibernate: create table hibernate_sequence (next_val bigint) type=MyISAM
  Apr 14, 2017 10:41:58 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
  INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@531f4093] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
  Apr 14, 2017 10:41:58 AM org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException
  WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:309)
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
      at com.test.hibernate14417.ExecuteUtil.buildSessionFactory(ExecuteUtil.java:29)
      at com.test.hibernate14417.ExecuteUtil.&lt;clinit&gt;(ExecuteUtil.java:20)
      at com.test.hibernate14417.Main.main(Main.java:21)
  Caused by: java.sql.SQLException: 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=MyISAM' at line 1
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
      at com.mysql.jdbc.Statement.execute(Statement.java:529)
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
      ... 13 more
  
  Hibernate: insert into hibernate_sequence values ( 1 )
  Apr 14, 2017 10:41:58 AM org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException
  WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:309)
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
      at com.test.hibernate14417.ExecuteUtil.buildSessionFactory(ExecuteUtil.java:29)
      at com.test.hibernate14417.ExecuteUtil.&lt;clinit&gt;(ExecuteUtil.java:20)
      at com.test.hibernate14417.Main.main(Main.java:21)
  Caused by: java.sql.SQLException: Table 'test.hibernate_sequence' doesn't exist
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
      at com.mysql.jdbc.Statement.execute(Statement.java:529)
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
      ... 13 more
  
  Hibernate: create table MyTable (id integer not null, name varchar(255), primary key (id)) type=MyISAM
  Apr 14, 2017 10:41:58 AM org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException
  WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
      at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:309)
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
      at com.test.hibernate14417.ExecuteUtil.buildSessionFactory(ExecuteUtil.java:29)
      at com.test.hibernate14417.ExecuteUtil.&lt;clinit&gt;(ExecuteUtil.java:20)
      at com.test.hibernate14417.Main.main(Main.java:21)
  Caused by: java.sql.SQLException: 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=MyISAM' at line 1
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
      at com.mysql.jdbc.Statement.execute(Statement.java:529)
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
      ... 13 more
  
  Apr 14, 2017 10:41:58 AM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
  INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@7776ab'
  Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
      at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:454)
      at com.test.hibernate14417.Main.main(Main.java:23)
  </code></pre>