package com.ssh.util;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static org.hibernate.SessionFactory sessionFactory;
private static Configuration configuration = new Configuration();
private static ServiceRegistry serviceRegistry;
static {
try {
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}
/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}
return session;
}
/**
* Rebuild hibernate session factory
*
*/
public static void rebuildSessionFactory() {
try {
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close();
}
}
/**
* return session factory
*
*/
public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
* return hibernate configuration
*
*/
public static Configuration getConfiguration() {
return configuration;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ssh_login1.0.zip_bootstrapValidator_gettingsrz_ssh
共217个文件
svn-base:101个
jpg:19个
js:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 35 浏览量
2022-09-23
20:25:30
上传
评论
收藏 9.04MB ZIP 举报
温馨提示
使用BootstrapValidator检验用户登录注册的信息,然后把符合的数据传递给后端进行数据判定,如果存在用户则进入主页,否则返回登录页面并显示错误信息
资源推荐
资源详情
资源评论
收起资源包目录
ssh_login1.0.zip_bootstrapValidator_gettingsrz_ssh (217个子文件)
HibernateSessionFactory.class 3KB
UserDAOImpl.class 2KB
LoginAction.class 1KB
registerAction.class 1KB
SuperAction.class 1KB
Users.class 1KB
BaseDAO.class 803B
UserDAO.class 211B
.classpath 2KB
org.eclipse.wst.common.component 495B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 143KB
style_19_common.css 137KB
bootstrap.min.css 135KB
font-awesome.css 37KB
font-awesome.min.css 35KB
bootstrap-theme.css 26KB
bootstrap-theme.min.css 25KB
login.css 3KB
bootstrapValidator.min.css 736B
bootstrapValidator.css 700B
wc.db 108KB
Thumbs.db 14KB
entries 2B
fontawesome-webfont.eot 162KB
glyphicons-halflings-regular.eot 20KB
format 2B
common_11_icon.gif 5KB
common_12_icon.gif 5KB
common_70_icon.gif 5KB
common_695_icon.gif 5KB
common_686_icon.gif 3KB
collapsed_no.gif 275B
collapsed_no.gif 275B
index.html 10KB
mysql-connector-java-5.1.44-bin.jar 976KB
HibernateSessionFactory.java 3KB
SuperAction.java 1KB
UserDAOImpl.java 1KB
registerAction.java 978B
LoginAction.java 901B
Users.java 883B
BaseDAO.java 472B
UserDAO.java 189B
1.jpg 453KB
BackGrounp2.jpg 418KB
BackGrounp1.jpg 391KB
BackGrounp3.jpg 386KB
BackGrounp4.jpg 244KB
2.jpg 202KB
default2.jpg 93KB
0.jpg 88KB
default1.jpg 54KB
default.jpg 30KB
default4.jpg 20KB
default6.jpg 14KB
default5.jpg 6KB
common_729_icon.jpg 4KB
common_360_icon.jpg 3KB
common_730_icon.jpg 3KB
common_741_icon.jpg 3KB
common_300_icon.jpg 2KB
captcha.jpg 2KB
jquery-3.3.1.js 265KB
bootstrapValidator.js 244KB
bootstrapValidator.min.js 141KB
jQuery1.7.js 92KB
jquery-1.8.2.min.js 91KB
jquery-3.3.1.min.js 85KB
jquery1.42.min.js 71KB
bootstrap.js 68KB
Validform_v5.3.2.js 44KB
bootstrap.min.js 43KB
Validform_v5.3.2_min.js 28KB
jquery.SuperSlide.js 11KB
npm.js 484B
.jsdtscope 564B
LoginPage.jsp 8KB
login_success.jsp 6KB
RegisterPage.jsp 6KB
RegisterSuccess.jsp 2KB
bootstrap.min.css.map 529KB
bootstrap.css.map 380KB
bootstrap-theme.css.map 47KB
bootstrap-theme.min.css.map 25KB
MANIFEST.MF 39B
.myhibernatedata 505B
org.eclipse.wst.jsdt.ui.superType.name 6B
FontAwesome.otf 132KB
common_13_icon.png 6KB
common_10_icon.png 5KB
copy_rignt_24.png 332B
org.eclipse.jdt.core.prefs 364B
org.eclipse.core.resources.prefs 80B
.project 1KB
.springBeans 458B
fontawesome-webfont.svg 434KB
glyphicons-halflings-regular.svg 106KB
c5c76a610587bde4af517e457bc66f8f0339caac.svn-base 976KB
e0d7b2bde55a0bac1b658a507e8ca491a6729e06.svn-base 529KB
共 217 条
- 1
- 2
- 3
资源评论
林当时
- 粉丝: 100
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功