public int getFruitCount() {
return (Integer) executeComplexQuery("select count(*) from t_fruit")[0];
}
Type Exception Report
Message java.lang.Long cannot be cast to java.lang.Integer
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
com.atguigu.fruit.dao.impl.FruitDaoImpl.getFruitCount(FruitDaoImpl.java:51)
com.atguigu.fruit.servlet.IndexServlet.service(IndexServlet.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
public int getFruitCount() {
return ((Long)executeComplexQuery("select count(*) from t_fruit")[0]).intValue();
}
注意Long类对象.intValue() ,不是long类型数值。