基于Struts+Hibernate开发过程中遇到的错误
2014-05-18 13:22
357 查看
1.import javax.servlet.http.HttpServletRequest 导入包出错
导入包出错,通常是包未引入,HttpServletRequest包是浏览器通过http发出的请求, 需要将tomcat/lib 目录下的 servlet-api.jar导入。但是导入后仍然不行,重启eclipse也无法让他生效
最后通过 project -clean来生效的。
2.JSP界面中加入了form标签后就报错
解决办法:将tomcat/lib目录下的el-api,ecj-4.3.1jre拷贝过来了
3.使用<c:forEach>标签,报错 Failed to load or instantiate TagLibraryValidator class
首先在jsp界面开头添加文件
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
然后在工程目录下WEB-INF/lib目录下添加
servlet-api.jar和standard.jar
4.Abandoned connection cleanup thread] but has failed to stop it. This is very
likely to create a memo
每次启动tomcat,没有关闭就启动,tomcat报内存泄露。解决就是关闭Eclipse,重启电脑。之后每次启动tomcat都是关闭后再启动。
5.使用MySQL数据库。root作为连接名,连接一段时间后出现连接被拒绝的情况
默认root用户不支持远程控制,在mysql控制台更改了root权限,仍然不起作用。最后使用了 navicat(mysql 可视化工具)创建了一个新用户,重新配置连接。
6.数据库表a,前台向a表写入一条数据,立即查询,发现没有表a没有更新。而查看数据库服务器中的表a,数据已经更新。但在myeclipse中重新连接数据库后。再查询时,数据得到更新。
查询方法是使用hibernate自动生成的dao
public List findByProperty(String propertyName, Object value) {
log.debug("finding Product instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Product as model where model."
+ propertyName + "= ?";
Query queryObject = getsession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
问题就是出现在session上。
hibernate框架操作数据库是通过org.hibernate.Session来实现的。而Session是由org.hibernate.SessionFactory来管理的。
Configuration conf=new Configuration().configure();//需要每次重新创建配置连接
org.hibernate.SessionFactory sessionFactory=conf.buildSessionFactory();
Session session=sessionFactory.openSession();
而自动生成的dao文件中getsession()方法中只有
public class BaseHibernateDAO implements IBaseHibernateDAO {
public Session getSession() {
return HibernateSessionFactory.getSession();
}
}
导入包出错,通常是包未引入,HttpServletRequest包是浏览器通过http发出的请求, 需要将tomcat/lib 目录下的 servlet-api.jar导入。但是导入后仍然不行,重启eclipse也无法让他生效
最后通过 project -clean来生效的。
2.JSP界面中加入了form标签后就报错
解决办法:将tomcat/lib目录下的el-api,ecj-4.3.1jre拷贝过来了
3.使用<c:forEach>标签,报错 Failed to load or instantiate TagLibraryValidator class
首先在jsp界面开头添加文件
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
然后在工程目录下WEB-INF/lib目录下添加
servlet-api.jar和standard.jar
4.Abandoned connection cleanup thread] but has failed to stop it. This is very
likely to create a memo
每次启动tomcat,没有关闭就启动,tomcat报内存泄露。解决就是关闭Eclipse,重启电脑。之后每次启动tomcat都是关闭后再启动。
5.使用MySQL数据库。root作为连接名,连接一段时间后出现连接被拒绝的情况
默认root用户不支持远程控制,在mysql控制台更改了root权限,仍然不起作用。最后使用了 navicat(mysql 可视化工具)创建了一个新用户,重新配置连接。
6.数据库表a,前台向a表写入一条数据,立即查询,发现没有表a没有更新。而查看数据库服务器中的表a,数据已经更新。但在myeclipse中重新连接数据库后。再查询时,数据得到更新。
查询方法是使用hibernate自动生成的dao
public List findByProperty(String propertyName, Object value) {
log.debug("finding Product instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Product as model where model."
+ propertyName + "= ?";
Query queryObject = getsession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
问题就是出现在session上。
hibernate框架操作数据库是通过org.hibernate.Session来实现的。而Session是由org.hibernate.SessionFactory来管理的。
Configuration conf=new Configuration().configure();//需要每次重新创建配置连接
org.hibernate.SessionFactory sessionFactory=conf.buildSessionFactory();
Session session=sessionFactory.openSession();
而自动生成的dao文件中getsession()方法中只有
public class BaseHibernateDAO implements IBaseHibernateDAO {
public Session getSession() {
return HibernateSessionFactory.getSession();
}
}
相关文章推荐
- 基于Struts+Hibernate开发过程中遇到的错误
- 在spring+hibernate框架的java项目开发过程中,经常会遇到这样的错误: could not find a getter for ... in class ...
- 一个基于SSH的实践项目在开发过程中遇到的问题汇总
- hibernate开发遇到的错误及解决办法
- [置顶] Cocos2d-x使用过程中遇到的错误(VS下开发,移植到Android发布)(更新ing)
- MVC3.0 开发过程中遇到错误及解决方案(不断更新中。。。)
- ArcGis开发过程中遇到HRESULT:0x80040213错误:
- 用Hibernate开发遇到"No CurrentSessionContext configured"错误
- 我的成长比价系列:java web开发过程中遇到的错误一:sql语句换行错误
- android开发过程遇到的一些错误
- 用Hibernate开发遇到"No CurrentSessionContext configured"错误
- hibernate开发遇到的错误及解决办法
- 用Hibernate开发遇到"No CurrentSessionContext configured"错误
- NDK开发过程中有时候在eclipse里会遇到其无法处理inclusion导致symbol显示错误
- Cocos2d-x使用过程中遇到的错误(VS下开发,移植到Android发布)
- java项目开发过程中可能会遇到的错误大搜集
- 一次项目开发过程中遇到的问题--错误的表单校验导致我的整个系统宕机
- hibernate 开发学习过程中遇到的问题:
- Cocos2d-x使用过程中遇到的错误(VS下开发,移植到Android发布)(更新ing)
- Android开发过程中遇到的错误及其解决的方法