一个关于hibernate的问题

chatboycsdn 2004-04-15 03:20:25
我做了一个hibernate的简单程序,发布到tomcat4.18中后,在jsp中通过javabean调用
可是jsp中抛出了很多异常
在tomcat的控制台上,最后输出的信息是
信息: Query language substitutions: {no='N', true=1, yes='Y', false=0}
2004-3-28 10:08:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
信息: cache provider: net.sf.ehcache.hibernate.Provider
2004-3-28 10:08:15 net.sf.hibernate.cfg.Configuration configureCaches
信息: instantiating and configuring caches
2004-3-28 10:08:15 net.sf.hibernate.impl.SessionFactoryImpl <init>
信息: building session factory
就走到building session factory这句就停了,谁知道为什么吗?我用的是hibernate2.12的版本
...全文
85 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
steven760812 2004-07-08
  • 打赏
  • 举报
回复
看一下你的hibernate.cfg.xml文件是否导入相应的数据库表的xml文件已经存在
fanciex 2004-07-08
  • 打赏
  • 举报
回复
看不出来,看log吧。
chatboycsdn 2004-04-15
  • 打赏
  • 举报
回复
帮忙看看有没有问题啊
chatboycsdn 2004-04-15
  • 打赏
  • 举报
回复
package com.demo.util;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;

public class HibernateUtil {

private static final SessionFactory sessionFactory;

static {
try {
sessionFactory =
new Configuration().configure().buildSessionFactory();
} catch (HibernateException ex) {
throw new RuntimeException(
"Exception building SessionFactory: " + ex.getMessage(),
ex);
}
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}


//调用

public class AccessLoginDemo{
public boolean AddLogin(String loginid,String loginpwd) {
try {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
LoginDemo login=new LoginDemo();
login.setLoginId(loginid);
login.setLoginPwd(loginpwd);
login.setLoginName(loginname);
session.save(login);
tx.commit();
HibernateUtil.closeSession();
} catch (HibernateException e) {
e.printStackTrace();
return false;
}
return true;
}
}
ji66 2004-04-15
  • 打赏
  • 举报
回复
正常的hibernate也有那一句

你的session代码是怎么写的,贴出来
chatboycsdn 2004-04-15
  • 打赏
  • 举报
回复
who can help me?
chatboycsdn 2004-04-15
  • 打赏
  • 举报
回复
帮忙啊

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧