title: Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
body: <p>I am using hibernate 5 with orcale 12c and java 9
  When i execute this code error occur hibernate could not execute statement</p>
  
  <p>I wrote easy program at Hibernate and caught bunch of exception .</p>
  
  <p>I couldn't find out what the exactly thing is wrong.</p>
  
  <p>I have three classes - student, main and hibernate.cfg,xml. </p>
  
  <p>this is very simple hibernate code which involve only one class which is student class</p>
  
  <h3>STUDENT.JAVA</h3>
  
  <pre><code>package hibernate.demo.entity;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  //@Table(name="student")
  public class Student {
  
      @Id
  //  @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name="id")
      private int id;
  
      @Column(name="first_Name")
      private String firstName;
  
      @Column(name="last_Name")
      private String lastName;
  
      @Column(name="email")
      private String email;
  
      public Student() {
  
      }
      public Student(String firstName, String lastName, String email) {
          super();
          this.firstName = firstName;
          this.lastName = lastName;
          this.email = email;
      }
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getFirstName() {
          return firstName;
      }
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
      public String getLastName() {
          return lastName;
      }
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
      public String getEmail() {
          return email;
      }
      public void setEmail(String email) {
          this.email = email;
      }
      @Override
      public String toString() {
          return "Student [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + "]";
      }
  
  }
  </code></pre>
  
  <h2>hibernate.cfg.xml</h2>
  
  <pre><code>&lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  
      &lt;session-factory&gt;
  
          &lt;!-- JDBC Database connection settings --&gt;
  
          &lt;property name="connection.url"&gt;jdbc:oracle:thin:@localhost:1521:orcl&lt;/property&gt;
          &lt;property name="connection.username"&gt;scott&lt;/property&gt;
          &lt;property name="connection.password"&gt;tiger&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
          &lt;!-- JDBC connection pool settings ... using built-in test pool --&gt;
          &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;!-- Select our SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/property&gt;
  
          &lt;!-- Echo the SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
          &lt;!-- Set the current session context --&gt;
          &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <h2>main class</h2>
  
  <pre><code>package hibernate.demo;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  import hibernate.demo.entity.Student;
  
  public class ClassStudentDemo {
  
      public static void main(String[] args) {
  
          // create session factory
          SessionFactory factory = new Configuration()
                  .configure("hibernate.cfg.xml")
                  .addAnnotatedClass(Student.class)
                  .buildSessionFactory();
  
          //create session
  
          Session session = factory.getCurrentSession();
  
          try {
              //create student object
              System.out.println("creating new Student object...");
              Student tempStudent = new Student("sohaib","ahmed","sohaibahmedawan@gmail.com");
  
              //start a transaction
              session.beginTransaction();
  
              //save the student object
              System.out.println("Saving the student....");
              session.save(tempStudent);
  
              ///commit transaction
              session.getTransaction().commit();
  
              System.out.println("Done!!!");
          }
          finally {
              factory.close();
          }
  
      }
  </code></pre>
  
  <h2>error</h2>
  
  <pre><code>Jan 24, 2019 12:36:27 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.4.1.Final}
  Jan 24, 2019 12:36:27 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
  Jan 24, 2019 12:36:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  Jan 24, 2019 12:36:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001005: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:orcl]
  Jan 24, 2019 12:36:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001001: Connection properties: {password=****, user=scott}
  Jan 24, 2019 12:36:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001003: Autocommit mode: false
  Jan 24, 2019 12:36:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections &lt;init&gt;
  INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
  Jan 24, 2019 12:36:29 PM org.hibernate.dialect.Dialect &lt;init&gt;
  INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
  creating new Student object...
  Saving the student....
  Hibernate: insert into Student (email, first_Name, last_Name, id) values (?, ?, ?, ?)
  Jan 24, 2019 12:36:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  WARN: SQL Error: 942, SQLState: 42000
  Jan 24, 2019 12:36:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  ERROR: ORA-00942: table or view does not exist
  
  Jan 24, 2019 12:36:31 PM org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure
  ERROR: HHH000346: Error during managed flush [org.hibernate.exception.SQLGrammarException: could not execute statement]
  Jan 24, 2019 12:36:31 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PoolState stop
  INFO: HHH10001008: Cleaning up connection pool [jdbc:oracle:thin:@localhost:1521:orcl]
  Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1490)
      at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:515)
      at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3348)
      at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2519)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
      at hibernate.demo.ClassStudentDemo.main(ClassStudentDemo.java:36)
  Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3175)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3689)
      at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1484)
      ... 9 more
  Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
  
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:58)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:943)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3897)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1361)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
      ... 17 more
  </code></pre>