session.save(user);//为什么重复使用两次
session.close();//最好放到finally中
session.close();//最好放到finally中
解决方案 »
- 关于Calendar的一个小问题
- struts2 HTTP ERROR: 503 Service Unavailable 错误
- 日期的转换出错
- struts2问题!!!
- struts分模块开发具体怎样建立各模块的
- 关于EJB CMP的插入的违反唯一约束错误,大侠们帮我看看
- 高手帮忙:为什么在对一个表操作的事务提交之前,对这个表进行select 操作就报错呢??
- 为什么会出现RMI连接拒绝错误?
- 在EJB的CMP中实现多个条件查询????
- jbuilder搭配weblogic还是websphere好?
- js 正则表达式问题
- 现有三星液晶显示器专用底座两个(可实现屏幕旋转)价格200人民币)加qq 471129123
SOS
SOS
还有,在 SessionFactory sf = new Configuration().configure().buildSessionFactory();
这个之前是不是要先加载类吧,这样写试试
Configuration cfg=new Configuratiion();
cfg.add(User.class);
SessionFactory sf = cfg.buildSessionFactory();
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.其他的配置文件自己检查一下
<?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>
对吗???