2014年12月29日09:48:19 天氣晴 心情好
①、今天在整合三大框架的時候,出現了兩個異常,在網上看了很多的文章。所有的文章都指向hibernate的問題,於是我就從這幾方面去排查,一:hibernatejar包,二:hibernate配置文件,三:hibernate的實體映射文件(我用的是註解的方式來的)。經過一一排查後發現,我把id的類型寫成了string的類型。
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:80)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:91)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'mydb.tbl_employee' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
②、在做刪除功能時,發現數據庫已經刪除了數據,但是跳轉的時候卻出現404的異常。經過檢查,發現在sturts.xml配置文件中<result name="listAllEmps">/employee!listAllEmps.action</result>,因爲result的type屬性默認的值是dipatcher,而我需要是重定向到這個action下,所以添加了
type="redirect"就可以了