站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Eclipse 专题高分请教MyEclipse4.0+Hibernate2.1连MySQL数据库问题!分嫌少再加!

高分请教MyEclipse4.0+Hibernate2.1连MySQL数据库问题!分嫌少再加!

摘要: 高分请教MyEclipse4.0+Hibernate2.1连MySQL数据库问题!分嫌少再加!


错误如下:
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Resource: Add valid path not found

AddVipData.jsp请求内容如下:

<%@ page import="com.antong.hibernate.VipService"%>
<%@ page import="java.util.List"%>
...
<%
List vipList = VipService.getInstance().getVipdataList();
request.setAttribute("vipdatas", vipList);
%>
...

VipService.java内容如下:
...
public List getVipdataList(){
Session session = null;

try{
session = SessionFactory.currentSession();
//创建一条HQL查询
Query query=session.createQuery("select Vipdata from com.antong.Hibernate.Vipdata Vipdata order by Vipdata.vipName");
return query.list();
}
catch(HibernateException e){
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}
finally{
if(session != null){
try{
//关闭session
session.close();
}
catch(HibernateException e){
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}
}
}
}
...
这里只给出一个方法,文件并无错误。

其它的hibernate.vfg.xml、SessionFactory.java、Vipdata.java、AbstractVipdata.java都是MyEclipse自动生成的;

hibernate.vfg.xml内容如下:
<?xml version='1.0' encoding='UTF-8'?>
hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">


↑返回目录
前一篇: -lt
后一篇: SWT designer过期后大家是怎么注册的阿?