在线投票系统代码和课程设计


这是一个用来做课程设计最好的在线投票系统,很适合用。
资源截图
代码片段和文件信息
package cn.cy.vote.dao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

/**
 * 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 String CONFIG_FILE_LOCATION = “/cn/cy/vote/dao/hibernate.cfg.xml“;
private static final ThreadLocal threadLocal = new ThreadLocal();
    private  static Configuration configuration = new Configuration();    
    private static org.hibernate.SessionFactory sessionFactory;
    private static String configFile = CONFIG_FILE_LOCATION;

static {
     try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println(“%%%% Error Creating SessionFactory %%%%“);
e.printStackTrace();
}
    }
    private HibernateSessionFactory() {
    }

/**
     * Returns the ThreadLocal Session instance.  Lazy initialize
     * the SessionFactory 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(configFile);
sessionFactory = configuration.buildSessionFactory();
} 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 session factory
     *
     * session factory will be rebuilded in the next call
     */
public static void setConfigFile(String co

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-06-07 08:41  课程设计
     文件      221696  2012-06-07 08:40  课程设计906603-15 匡献威.doc
     目录           0  2012-06-05 20:07  课程设计vote3
     文件         835  2012-05-31 12:15  课程设计vote3.classpath
     目录           0  2012-06-05 20:07  课程设计vote3.myeclipse
     文件         570  2012-05-31 09:51  课程设计vote3.myhibernatedata
     文件         287  2012-06-03 20:13  课程设计vote3.mymetadata
     文件        2158  2012-06-03 20:13  课程设计vote3.project
     目录           0  2012-06-05 20:07  课程设计vote3.settings
     文件         493  2012-05-31 09:48  课程设计vote3.settings.jsdtscope
     文件         395  2012-05-31 09:48  课程设计vote3.settingsorg.eclipse.jdt.core.prefs
     文件         450  2012-05-31 09:48  课程设计vote3.settingsorg.eclipse.wst.common.component
     文件         252  2012-05-31 09:48  课程设计vote3.settingsorg.eclipse.wst.common.project.facet.core.xml
     文件          49  2012-05-31 09:48  课程设计vote3.settingsorg.eclipse.wst.jsdt.ui.superType.container
     文件           6  2012-05-31 09:48  课程设计vote3.settingsorg.eclipse.wst.jsdt.ui.superType.name
     文件         415  2012-05-31 12:15  课程设计vote3.springBeans
     目录           0  2012-06-05 20:07  课程设计vote3src
     目录           0  2012-06-05 20:07  课程设计vote3srccn
     目录           0  2012-06-05 20:07  课程设计vote3srccncy
     目录           0  2012-06-05 20:07  课程设计vote3srccncyvote
     目录           0  2012-06-05 20:07  课程设计vote3srccncyvotedao
     文件        1023  2012-06-01 12:04  课程设计vote3srccncyvotedaohibernate.cfg.xml
     文件        3230  2012-05-31 09:51  课程设计vote3srccncyvotedaoHibernateSessionFactory.java
     文件        1473  2012-06-03 12:07  课程设计vote3srccncyvotedaoHibernateUtil.java
     目录           0  2012-06-05 20:07  课程设计vote3srccncyvotedaoimpl
     文件         623  2012-06-04 20:33  课程设计vote3srccncyvotedaoimplDaoFactory.java
     文件        1471  2012-06-03 12:01  课程设计vote3srccncyvotedaoimplUserDaoImpl.java
     文件        1524  2012-06-03 12:58  课程设计vote3srccncyvotedaoimplVoteDaoImpl.java
     文件         345  2012-05-31 15:54  课程设计vote3srccncyvotedaoUserDao.java
     文件         353  2012-06-03 12:57  课程设计vote3srccncyvotedaoVoteDao.java
     目录           0  2012-06-05 20:07  课程设计vote3srccncyvotedomain
............此处省略68个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)