问题描述
异常信息:log4j:WARNNoappenderscouldbefoundforlogger(org.hibernate.cfg.Environment).log4j:WARNPleaseinitializethelog4jsystemproperly.Hibernate:selectDEPARTMENT_ID_SEQ.nextvalfromdualHibernate:insertintoStudent(name,age,_id)values(?,?,?)Exceptioninthread"main"org.hibernate.exception.SQLGrammarException:CouldnotexecuteJDBCbatchupdateatorg.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)atorg.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)atorg.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)atorg.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)atorg.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)atorg.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)atorg.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)atorg.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)atorg.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)attest.StudentTest.main(StudentTest.java:27)Causedby:java.sql.BatchUpdateException:ORA-00911:无效字符atoracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)atoracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)atorg.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)atorg.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)...8morestudent.hbm.xml----<?xmlversion="1.0"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mappingpackage="com.hibernate.pojo"><classname="Student"><idname="id"column="_id"><generatorclass="sequence"><paramname="sequence">DEPARTMENT_ID_SEQ</param></generator></id><propertyname="name"></property><propertyname="age"></property></class></hibernate-mapping>hibernate.cfg.xml----<?xmlversion='1.0'encoding='utf-8'?><!DOCTYPEhibernate-configurationPUBLIC"-//Hibernate/HibernateConfigurationDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><propertyname="connection.driver_class">oracle.jdbc.driver.OracleDriver</property><propertyname="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property><propertyname="connection.username">scott</property><propertyname="connection.password">tiger</property><propertyname="dialect">org.hibernate.dialect.Oracle9Dialect</property><propertyname="show_sql">true</property><!--Dropandre-createthedatabaseschemaonstartup--><propertyname="hbm2ddl.auto">update</property><mappingresource="com/hibernate/pojo/Student.hbm.xml"/></session-factory></hibernate-configuration>测试java代码:publicstaticvoidmain(String[]args){Students=newStudent();s.setId(1);s.setName("");s.setAge("");Configurationcf=newConfiguration();SessionFactoryse=cf.configure().buildSessionFactory();Sessionsession=se.openSession();session.beginTransaction();session.save(s);session.getTransaction().commit();session.close();se.close();}求解!!!!!!!!!!!!!!!
解决方案
解决方案二:
就这样啊。oracle不支持的字符?Causedby:java.sql.BatchUpdateException:ORA-00911:无效字符
解决方案三:
sql语句执行不了,应该是你的插入字段的类型和你表里的字段类型不一致!也可能是ls说的那样
解决方案四:
StudentTest.java:27这个地方代码是什么?Causedby:java.sql.BatchUpdateException:ORA-00911:无效字符
解决方案五:
让人费解