如何在hibernate中创建一个表,该表不会在数据库中退出

时间:2015-06-29 03:34:46

标签: java xml hibernate

我从hibernate得到这个例外请给我建议解决这个问题

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

1 个答案:

答案 0 :(得分:0)

如果您注意到

,则信息非常清晰
  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')