资源简介

spring是一站式框架,当然也对数据持久层做了一部分的处理。spring通过JdbcTemplate对数据操作。本案例详细介绍了spring的jdbcTemplate和c3p0的整合。

资源截图

代码片段和文件信息

package cn.ies.c3p0;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathxmlApplicationContext;

import cn.ies.jdbc.User;

public class TestUserService {

@Test
public void testInsert() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
userService.testInsert();
}

@Test
public void testUpdate() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
userService.testUpdate();
}

@Test
public void testDelete() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
userService.testDelete();
}


@Test
public void testCount() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
int count =userService.testCount();
System.out.println(count);
}

@Test
public void testobject() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
User user = userService.testobject(“ytek“);
System.out.println(user==null);
}

@Test
public void testList() {
ApplicationContext context =
new ClassPathxmlApplicationContext(“bean.xml“);
UserService userService = (UserService) context.getBean(“userService“);
List list = userService.testList(“tt“);
System.out.println(list.toString());
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-12 08:27  JdbcTemplate\
     文件         842  2018-06-12 08:27  JdbcTemplate\.classpath
     文件         912  2018-06-12 08:27  JdbcTemplate\.project
     目录           0  2018-06-12 08:27  JdbcTemplate\.settings\
     文件         567  2018-06-12 08:27  JdbcTemplate\.settings\.jsdtscope
     文件         364  2018-06-12 08:27  JdbcTemplate\.settings\org.eclipse.jdt.core.prefs
     文件         488  2018-06-12 08:27  JdbcTemplate\.settings\org.eclipse.wst.common.component
     文件         345  2018-06-12 08:27  JdbcTemplate\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-06-12 08:27  JdbcTemplate\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-06-12 08:27  JdbcTemplate\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-06-12 08:27  JdbcTemplate\build\
     目录           0  2018-06-12 11:51  JdbcTemplate\build\classes\
     文件        2291  2018-06-12 11:51  JdbcTemplate\build\classes\bean.xml
     文件         208  2018-06-12 11:48  JdbcTemplate\build\classes\c3p0config.properties
     目录           0  2018-06-12 10:59  JdbcTemplate\build\classes\cn\
     目录           0  2018-06-12 11:00  JdbcTemplate\build\classes\cn\ies\
     目录           0  2018-06-12 13:27  JdbcTemplate\build\classes\cn\ies\c3p0\
     文件        1075  2018-06-12 14:31  JdbcTemplate\build\classes\cn\ies\c3p0\MyRowMapper.class
     文件        2239  2018-06-12 14:31  JdbcTemplate\build\classes\cn\ies\c3p0\TestUserService.class
     文件        2999  2018-06-12 14:31  JdbcTemplate\build\classes\cn\ies\c3p0\UserDao.class
     文件        1334  2018-06-12 14:12  JdbcTemplate\build\classes\cn\ies\c3p0\UserService.class
     目录           0  2018-06-12 10:59  JdbcTemplate\build\classes\cn\ies\jdbc\
     文件        3538  2018-06-12 16:28  JdbcTemplate\build\classes\cn\ies\jdbc\JdbcTemplateTest.class
     文件        1235  2018-06-12 16:28  JdbcTemplate\build\classes\cn\ies\jdbc\MyMapper.class
     文件        1024  2018-06-12 10:59  JdbcTemplate\build\classes\cn\ies\jdbc\User.class
     目录           0  2018-06-12 10:02  JdbcTemplate\src\
     文件        2291  2018-06-12 11:51  JdbcTemplate\src\bean.xml
     文件         208  2018-06-12 11:48  JdbcTemplate\src\c3p0config.properties
     目录           0  2018-06-12 08:31  JdbcTemplate\src\cn\
     目录           0  2018-06-12 11:00  JdbcTemplate\src\cn\ies\
     目录           0  2018-06-12 11:23  JdbcTemplate\src\cn\ies\c3p0\
............此处省略28个文件信息

评论

共有 条评论