package edu.tongji.amazing.test;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.inject.Context;
import edu.tongji.amazing.action.LoginAction;
import edu.tongji.amazing.action.RegisterAction;
import edu.tongji.amazing.model.User;
public class TestHibernate {
private ApplicationContext context = null;
@Test
public void testName() throws Exception {
context = new ClassPathXmlApplicationContext("applicationContext.xml");
LoginAction user = (LoginAction) context.getBean("login");
// user.setUsername("happy");
// System.out.println("username is "+user.getUsername());
}
// public void createTable(){
// Configuration configuration = new Configuration().configure();
// @SuppressWarnings("deprecation")
// SchemaExport export = new SchemaExport(configuration);
// export.create(true, true);
// }
// @Test
public void testDataSource() throws SQLException{
context = new ClassPathXmlApplicationContext("applicationContext.xml");
// System.out.println(context);
DataSource datasource = context.getBean(DataSource.class);
// System.out.println(datasource.getConnection().toString());
SessionFactory factory = context.getBean(SessionFactory.class);
// System.out.println(factory);
// 打开session
Session session = factory.openSession();
// 开启事务
Transaction transaction = session.beginTransaction();
User user = new User();
user.setIdentity_id("130823199511258098");
user.setUsername("roth");
user.setPassword("123456");
session.save(user);
transaction.commit();
session.close();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Eclipse搭建的SSH框架
共97个文件
jar:48个
xml:8个
jsp:5个
5星 · 超过95%的资源 需积分: 10 128 下载量 14 浏览量
2016-03-21
21:08:35
上传
评论 1
收藏 19.62MB RAR 举报
温馨提示
SSH框架是Struts2.3.8+Spring3.2.16+Hibernate4.1.7,带junit4单元测试,加入bootstrap css 框架和Jquery,利用注解的方式使用hibernate和Spring,连接数据库oracle 12c。
资源推荐
资源详情
资源评论
收起资源包目录
AmazingAd.rar (97个子文件)
AmazingAd
.project 1KB
WebContent
WEB-INF
lib
commons-lang3-3.1.jar 308KB
asm-commons-3.3.jar 37KB
org-apache-commons-logging.jar 59KB
spring-instrument-3.2.16.RELEASE.jar 7KB
spring-core-3.2.16.RELEASE.jar 865KB
jboss-transaction-api_1.1_spec-1.0.0.Final.jar 11KB
dom4j-1.6.1.jar 307KB
hibernate-core-4.1.7.Final.jar 4.26MB
spring-test-3.2.16.RELEASE.jar 448KB
c3p0-0.9.1.jar 594KB
spring-orm-3.2.16.RELEASE.jar 377KB
hibernate-c3p0-4.1.7.Final.jar 41KB
spring-webmvc-portlet-3.2.16.RELEASE.jar 184KB
spring-aop-3.2.16.RELEASE.jar 331KB
spring-aspects-3.2.16.RELEASE.jar 50KB
spring-struts-3.2.16.RELEASE.jar 35KB
ojdbc7.jar 3.53MB
spring-instrument-tomcat-3.2.16.RELEASE.jar 10KB
javassist-3.15.0-GA.jar 633KB
struts2-dwr-plugin-2.3.8.jar 11KB
dwr-1.1.1.jar 180KB
junit-4.12.jar 308KB
freemarker-2.3.19.jar 909KB
hibernate-commons-annotations-4.0.1.Final.jar 79KB
commons-io-2.0.1.jar 156KB
spring-web-3.2.16.RELEASE.jar 617KB
asm-tree-3.3.jar 21KB
spring-webmvc-3.2.16.RELEASE.jar 627KB
hibernate-jpa-2.0-api-1.0.1.Final.jar 100KB
xwork-core-2.3.8.jar 604KB
commons-fileupload-1.2.2.jar 58KB
spring-oxm-3.2.16.RELEASE.jar 75KB
antlr-2.7.7.jar 435KB
struts2-spring-plugin-2.3.8.jar 21KB
hamcrest-core-1.3.jar 44KB
spring-jdbc-3.2.16.RELEASE.jar 397KB
spring-jms-3.2.16.RELEASE.jar 202KB
asm-3.3.jar 43KB
jboss-logging-3.1.0.GA.jar 59KB
jandex-1.1.0.Final.jar 75KB
spring-context-support-3.2.16.RELEASE.jar 126KB
spring-tx-3.2.16.RELEASE.jar 237KB
spring-context-3.2.16.RELEASE.jar 848KB
struts2-core-2.3.8.jar 775KB
struts2-dojo-plugin-2.3.8.jar 1.65MB
ognl-3.0.6.jar 223KB
spring-beans-3.2.16.RELEASE.jar 600KB
spring-expression-3.2.16.RELEASE.jar 192KB
web.xml 1KB
Libs
bootstrap
js
npm.js 484B
bootstrap.js 67KB
bootstrap.min.js 36KB
fonts
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff2 18KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.svg 106KB
glyphicons-halflings-regular.woff 23KB
css
bootstrap-theme.css.map 47KB
bootstrap.min.css 120KB
bootstrap-theme.min.css 23KB
bootstrap-theme.css 26KB
bootstrap.css.map 381KB
bootstrap.css 144KB
Jquery
jquery-1.12.1.js 287KB
Website
CSS
JavaScript
src
pictures
avtar.jpg 34KB
Pages
register.jsp 2KB
index.jsp 3KB
success.jsp 366B
fail.jsp 366B
login.jsp 612B
META-INF
MANIFEST.MF 39B
src
struts.xml 1KB
applicationContext.xml 3KB
oracle.properties 144B
edu
tongji
amazing
service
action
LoginAction.java 711B
RegisterAction.java 728B
serive
impl
model
User.java 1KB
dao
impl
util
test
TestHibernate.java 2KB
tool
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 234B
org.eclipse.wst.common.component 479B
.jsdtscope 567B
build
classes
struts.xml 1KB
applicationContext.xml 3KB
oracle.properties 144B
config
struts.xml 1KB
applicationContext.xml 3KB
oracle.properties 144B
edu
tongji
amazing
service
action
RegisterAction.class 1KB
LoginAction.class 1KB
serive
impl
model
User.class 1KB
dao
impl
util
test
TestHibernate.class 2KB
tool
.classpath 841B
共 97 条
- 1
资源评论
- sinat_248972152018-03-10还可以,省去了我自己搭建的的时间
- erpang2262016-03-22还可以,省去了我自己搭建的的时间
AAArlex
- 粉丝: 97
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功