当前位置: 首页 > wzjs >正文

东营确诊名单湖南网站seo找行者seo

东营确诊名单,湖南网站seo找行者seo,潍坊做网站公司,wordpress保存文件路径JdbcTemplate概述 它是spring框架中提供的一个对象,是对原始繁琐的JdbcAPI对象的简单封装。spring框架为我们提供了很多的操作模板类。例如:操作关系型数据的JdbcTemplate和MbernateTemplate,操作nosql数据库的RedisTemplate,操作消息队列的…

JdbcTemplate概述

它是spring框架中提供的一个对象,是对原始繁琐的JdbcAPI对象的简单封装。spring框架为我们提供了很多的操作模板类。例如:操作关系型数据的JdbcTemplate和MbernateTemplate,操作nosql数据库的RedisTemplate,操作消息队列的JmsTemplate等等。

JdbcTemplate开发步骤

① 导入spring-jdbc和spring-tx坐标

② 创建数据库表和实体

③ 创建JdbcTemplate对象

④ 执行数据库操作

@Test// 测试JdbcTemplate的开发步骤public void test2() throws PropertyVetoException {ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");JdbcTemplate jdbcTemplate = app.getBean(JdbcTemplate.class);int row = jdbcTemplate.update("insert into account values(?, ?)", "lisi11", 1000);System.out.println(row);}//-----------------------------------------------------<?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"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><!--    加载jdbc.properties--><context:property-placeholder location="classpath:jdbc.properties"/><!--    数据源对象--><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="driverClass" value="${jdbc.driver}"/><property name="jdbcUrl" value="${jdbc.url}"/><property name="user" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/></bean><!--    jdbc模板对象--><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource" ref="dataSource"/></bean></beans>//----------------------------------------------jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=1234

 JdbcTemplate基本使用-常用操作-更新删除操作

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class JdbcTemplateCRUDTest {@Autowiredprivate JdbcTemplate jdbcTemplate;@Testpublic void testUpdate(){jdbcTemplate.update("update account set money = ? where name = ?",10001, "wangwu");}@Testpublic void testDelete(){jdbcTemplate.update("delete from account where money = ?", 10001);}
}

 JdbcTemplate基本使用-常用操作-查询操作

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class JdbcTemplateCRUDTest {@Autowiredprivate JdbcTemplate jdbcTemplate;@Testpublic void testUpdate(){jdbcTemplate.update("update account set money = ? where name = ?",10001, "wangwu");}@Testpublic void testDelete(){jdbcTemplate.update("delete from account where money = ?", 10001);}//查询多个@Testpublic void estQuery(){List<Account> accountList = jdbcTemplate.query("select * from account", new BeanPropertyRowMapper<Account>(Account.class));System.out.println(accountList);}//查询一个@Testpublic void testQueryOne(){List<Account> accountList = jdbcTemplate.query("select * from account where name=?", new BeanPropertyRowMapper<Account>(Account.class), "lisi");System.out.println(accountList);}//聚合查询@Testpublic void testQueryCount(){Long count = jdbcTemplate.queryForObject("select count(*) from account", Long.class);System.out.println(count);}
}

http://www.dtcms.com/wzjs/486010.html

相关文章:

  • asp网站添加背景音乐网站制作软件免费下载
  • 网站如何做seo排名经典广告
  • 如何推广企业网站营销推广公司
  • 湖北省建设厅建筑资料官方网站怎么申请网站
  • 广州网站建设哪好深圳搜索排名优化
  • 网站备案和实际的不同宁波seo公司推荐
  • 山东青岛68元建网站郑州网站建设价格
  • 饮料网站建设规划书免费进入b站2022年更新
  • 新闻标题做的好的网站app开发定制
  • 可以做外包的网站东莞网站建设公司
  • 网站建设 国外爱站
  • 南通旅游网站建设机构类网站有哪些
  • 网站的倒计时怎么做的写文章免费的软件
  • 镇江网站关键字优化机构百度问一问免费咨询
  • 百度收录好的网站百度收录怎么弄
  • 广州市建设监理协会网站网站设计公司多少钱
  • 赣州网站建设渠道b站视频推广
  • 辛集建设网站公司网站怎么申请怎么注册
  • 网站建设网站维护的具体内容是什么seo整站优化服务教程
  • 做展示空间设计的网站2023第二波疫情已经到来
  • 建设公司网站源码优化关键词排名seo软件
  • 免费网站建设公司代理seo网站优化排名
  • 深圳网站制作的公司外链屏蔽逐步解除
  • wordpress 表单录入百度关键词搜索引擎排名优化
  • 网站开发用哪个程序网络营销方式都有哪些
  • wap网站做微信小程序网站生成器
  • 定制型网站制作推广普通话文字内容
  • 关于电子商务网站建设的参考文献谷歌官网入口手机版
  • jsp做网站下载图片全国各城市疫情高峰感染高峰进度
  • 网站在线客服软件网站营销方案模板