首先,找齐Spring框架中IoC功能、aop功能、JdbcTemplate功能所需的jar包,当前13个Jar包

1、Spring压缩包中的四个核心JAR包,实现IoC控制反转的根据xml配置文件或注解生成对象

beans 、context、core 和expression

下载地址:

https://pan.baidu.com/s/1qXLHzAW

2、以及日志jar包,以便查看相关执行细节

commons-logging 和log4j

下载地址:

https://pan.baidu.com/s/1mimTW5i

3、再增加一个

spring-aop-5.0.1.RELEASE.jar (用于注解,在Spring-framework库中包含)

4、再增加

spring-aspects-5.0.1.RELEASE.jar (在Spring-framework库中包含)

aspectjweaver-1.8.12.jar (官方下载地址 http://mvnrepository.com/artifact/org.aspectj/aspectjweaver)

aopalliance-1.0.jar            (官方下载地址 http://mvnrepository.com/artifact/aopalliance/aopalliance/1.0)

实现aop功能,增强相关的切入点

5、JdbcTemplate功能所需Jar包

spring-jdbc-4.2.4.RELEASE.jar

spring-tx-4.2.4.RELEASE.jar

spring 框架jar包下载地址

链接: https://pan.baidu.com/s/1bpydNGV 密码: 2kvk

6、连接mysql数据库jar包

mysql-connector-java-5.1.7-bin.jar

下载地址:链接: https://pan.baidu.com/s/1geBRqqn 密码: 8jxm


应用Spring框架的JdbcTemplate方法删除数据库中数据

package com.swift;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Component; @Component(value="jdbcTemplateDemo")
public class JdbcTemplateDemo { public boolean delete(String username) {
DriverManagerDataSource dataSource=new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/sw_database");
dataSource.setUsername("root");
dataSource.setPassword("root"); JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
int count=jdbcTemplate.update("delete from sw_user where username=?", username);
if(count!=0) {
return true;
}
return false;
}
}

注解方法生成对象,所需xml配置文件代码:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 开启注解扫描——对象和属性 -->
<context:component-scan base-package="com.swift"></context:component-scan>
<!-- 开启aop注解方法 -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy> </beans>

调用JdbcTemplate删除数据库信息的Servlet类代码:

package com.swift;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; @WebServlet("/test")
public class ServletTest extends HttpServlet {
private static final long serialVersionUID = 1L; public ServletTest() {
super();
} protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
@SuppressWarnings("resource")
ApplicationContext context=new ClassPathXmlApplicationContext("aop.xml");
JdbcTemplateDemo jdbcTemplateDemo=(JdbcTemplateDemo) context.getBean("jdbcTemplateDemo");
if(jdbcTemplateDemo.delete("wangwu")) {
response.getWriter().append("delete success!");
}else {
response.getWriter().append("delete success!");
}
} protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
} }

Spring框架针对dao层的jdbcTemplate操作crud之delete删除数据库操作 Spring相关Jar包下载的更多相关文章

  1. Spring框架针对dao层的jdbcTemplate操作之jdbc数据库连接原始操作方法 所需安装包下载

    crud指数据库或者持久层的基本操作,包括 增加(Create).读取查询(Retrieve 取回).更新(Update)和删除(Delete) Spring不仅对JDBC进行了封装,也对Hibern ...

  2. Spring框架针对dao层的jdbcTemplate操作crud之query查询数据操作

    查询目标是完成3个功能: (1)查询表,返回某一个值.例如查询表中记录的条数,返回一个int类型数据 (2)查询表,返回结果为某一个对象. (3)查询表,返回结果为某一个泛型的list集合. 一.查询 ...

  3. Spring框架针对dao层的jdbcTemplate操作crud之update修改数据库操作

    使用jdbcTemplate 原理是把加载驱动Class.forName("com.mysql.jdbc.Driver"); 和连接数据库Connection conn=Drive ...

  4. Spring框架针对dao层的jdbcTemplate操作crud之add添加数据库操作

    使用jdbcTemplate 原理是把加载驱动Class.forName("com.mysql.jdbc.Driver"); 和连接数据库Connection conn=Drive ...

  5. Spring框架针对dao层的jdbcTemplate操作crud之query查询数据操作 —— 查询表,返回结果为对象的list集合

    用JdbcTemplate的方法完成, 查询数据库表,把用户表sw_user所有数据以List<User>集合返回 在JdbcTemplateDemo类中增加查询返回所有对象集合的方法qu ...

  6. 解决Spring框架的Dao层改用@Repository注解,无法使用JdbcDaoSupport的问题

    解决Spring框架的Dao层改用@Repository注解,无法使用JdbcDaoSupport的问题 Alternatively, create an own implementation of ...

  7. ssh整合思想 Spring与Hibernate的整合ssh整合相关JAR包下载 .MySQLDialect方言解决无法服务器启动自动update创建表问题

    除之前的Spring相关包,还有structs2包外,还需要Hibernate的相关包 首先,Spring整合其他持久化层框架的JAR包 spring-orm-4.2.4.RELEASE.jar  ( ...

  8. Spring、MyBatis和SpringMVC整合的jar包下载

    spring mvc的jar包下载:http://repo.springsource.org/libs-release-local/org/springframework/spring/我下载的5.0 ...

  9. Spring配置连接池和 Dao 层使用 jdbcTemplate

    1.Spring 配置 c3p0 连接池 (1)导入jar包(Maven项目) <dependency> <groupId>com.mchange</groupId> ...

随机推荐

  1. unity gl 画线

    using UnityEngine; using System.Collections; public class TGLLine : MonoBehaviour { private static M ...

  2. 洛谷P3312 [SDOI2014]数表(莫比乌斯反演+树状数组)

    传送门 不考虑$a$的影响 设$f(i)$为$i$的约数和 $$ans=\sum\limits_{i=1}^n\sum\limits_{j=1}^nf(gcd(i,j))$$ $$=\sum\limi ...

  3. [Xcode 实际操作]一、博主领进门-(9)Xcode左侧的项目导航区界面介绍

    目录:[Swift]Xcode实际操作 本文将演示Xcode的左侧操作界面. 项目的目录结构: 应用代理文件[AppDelegate.swift] 应用代理文件时系统运行本应用的委托,里面定义了如程序 ...

  4. Mol Cell Proteomics. |彭建祥| 人胃肠道间质瘤亚群蛋白质组图谱

    大家好,本周分享的是发表在Molecular & Cellular Proteomics 上的一篇关于人胃肠道间质瘤亚群蛋白质组图谱的文章,题目是Proteomic maps of human ...

  5. 最近工作用到压缩,写一个zip压缩工具类

    package test; import java.io.BufferedOutputStream;import java.io.File;import java.io.FileInputStream ...

  6. 归档-对模型数组对象(存储到本地的plist文件)也数组里存放的是模型

    一.模型文件 (1)JLMainViewsModel.h文件 必须遵循 NSCoding协议 @interface JLMainViewsModel : NSObject<NSCopying,N ...

  7. ZROI 部分题目题解

    ZROI 部分题目题解 335 首先发现一个性质: 对于最短的边而言,所有点的路径如果经过了这条边,那么路径的权值就是这条边的边权(废话) 那么我们把最短的边拎出来,可以发现,博物馆确定时,每个点按照 ...

  8. 105 Construct Binary Tree from Preorder and Inorder Traversal 从前序与中序遍历序列构造二叉树

    给定一棵树的前序遍历与中序遍历,依据此构造二叉树.注意:你可以假设树中没有重复的元素.例如,给出前序遍历 = [3,9,20,15,7]中序遍历 = [9,3,15,20,7]返回如下的二叉树:    ...

  9. D. Anton and Chess 模拟题 + 读题

    http://codeforces.com/contest/734/problem/D 一开始的时候看不懂题目,以为象是中国象棋那样走,然后看不懂样例. 原来是走对角线的,长知识了. 所以我们就知道, ...

  10. 在自己的linux服务器上面部署ShowDoc

    ShowDoc就是一个非常适合IT团队的在线文档分享工具,使用的是一款非常轻量级的关系数据库系统SQLite,支持多数SQL92标准.它可以加快团队之间沟通的效率. 但是把所有的接口文档写在第三方的服 ...