【问题标题】:how create a table in hibernate ,that table does not exit in database如何在休眠中创建一个表,该表在数据库中不存在
【发布时间】:2015-06-29 03:34:45
【问题描述】:

我从休眠中得到了这个异常,请给我建议来解决这个问题

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Hibernate: insert into PERSON1 (FIRSTNAME, LASTNAME, AGE, ID) values (?, ?, ?, ?)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
    at com.lara.Manager1.main(Manager1.java:23)
Caused by: java.sql.BatchUpdateException: ORA-00942: table or view does not exist

    at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 8 more

【问题讨论】:

  • 消息解释它:table or view does not exist。您可能没有名为 PERSON1 的表。

标签: java xml hibernate


【解决方案1】:

如果你注意到了,信息就很清楚了

  Caused by: java.sql.BatchUpdateException: ORA-00942: table or view does not exist

请检查您的数据库名称表。我认为这可能是一个拼写错误。首先尝试运行插入您的mysql或所需数据库的命令

insert into PERSON1 (FIRSTNAME, LASTNAME, AGE, ID) values ('ABC', 'XYZ', '18', 'id')

【讨论】:

  • 实际上数据库中没有 PERSON1 的表,但现在我正在尝试创建一个名为 PERSON1 的表。但它显示异常 org.hibernate.exception.SQLGrammerException:无法执行 JDBC 批处理更新
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-26
  • 2014-03-15
  • 1970-01-01
  • 2016-06-26
  • 1970-01-01
  • 2016-10-04
  • 1970-01-01
相关资源
最近更新 更多