session.save(user);//为什么重复使用两次
session.close();//最好放到finally中

解决方案 »

  1.   

    有人能帮帮忙吗!!!!!!
                   SOS
      

  2.   

    这不是个Applet程序嘛,你试着将这个Junit程序改造成Applet看看.
      

  3.   

    有人能帮帮忙吗!!!!!!
                   SOS
      

  4.   

    你有没有做配置文件啊,怎么没看到CONFIG的东东啊
    还有,在  SessionFactory sf = new Configuration().configure().buildSessionFactory();
    这个之前是不是要先加载类吧,这样写试试
    Configuration cfg=new Configuratiion();
    cfg.add(User.class);
    SessionFactory sf = cfg.buildSessionFactory();
      

  5.   

    如果你非要是这样测试那么
    1.在你的web.xml文件中把你的spring的配置文件配好eg:
    <listener> 
         <listener-class> 
              org.springframework.web.context.ContextLoaderListener 
         </listener-class> 
    </listener>
    2.在web.xml中指定你的spring配置文件的路径eg:
    <context-param> 
           <param-name>contextConfigLocation</param-name> 
           <param-value>/WEB-INF/xxxxxxxx.xml</param-value> 
    </context-param>
    3.用mian()函数测试应该这样些
    public static void main(String[] args) {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("dao-config.xml");
    ResumeInfoDAO resumeInfoDAO = (ResumeInfoDAO) applicationContext.getBean("resumeInfoDAO");
    List resumeList = resumeInfoDAO.queryResumeInfo();
    User user= null;
    for(int i = 0, n = resumeList.size(); i < n; i++) {
    user= (User )resumeList.get(i);
    System.out.println("user.name === " + user.getUserName());
    }
    }
    4.其他的配置文件自己检查一下
      

  6.   

    这是配置文件!!!!
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>    <session-factory>

            <!-- Database connection settings -->
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.url">jdbc:mysql://localhost:3306/MyProject</property>
            <property name="connection.username">root</property>
            <property name="connection.password">yang</property>        <!-- JDBC connection pool (use the built-in) -->
            <property name="connection.pool_size">1</property>        <!-- SQL dialect -->
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>        <!-- Enable Hibernate's automatic session context management -->
            <property name="current_session_context_class">thread</property>        <!-- Disable the second-level cache  -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>        <!-- Echo all executed SQL to stdout -->
            <property name="show_sql">true</property>        <!-- Drop and re-create the database schema on startup -->
            <property name="hbm2ddl.auto">create</property>        <mapping resource="ch03/hibernate/User.hbm.xml"/>    </session-factory></hibernate-configuration>
    对吗???