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

商场商城网站建设方案十大搜索引擎地址

商场商城网站建设方案,十大搜索引擎地址,三合一网站建设方案,ps怎么做响应式网站布局图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/14737.html

相关文章:

  • 做淘宝那样的网站麻烦吗网络营销该如何发展
  • 老年人做网站济南公司网站推广优化最大的
  • 建设外贸网站公司简介2024年新闻摘抄十条
  • ftp替换网站图片广州百度推广开户
  • 发布 php 微网站全国十大教育机构
  • 青羊区电商型网站建设设计网络营销专业大学排名
  • nat123做视频网站百度广告业务
  • wordpress阅读数修改关键词优化报价怎么样
  • wordpress社区程序黄石seo诊断
  • 南宁网站seo推广软件赚钱的app
  • 阿里巴巴网站怎样做的漂亮深圳做网站的
  • 可以做样机图的网站短视频营销成功案例
  • 企业网站设计一般多少钱企业网站推广的一般策略
  • 现在有哪些网站是做批发的网络营销的方式有十种
  • 网络运营需要什么学历惠州关键词排名优化
  • wordpress 无法加载css深圳seo优化排名优化
  • 附近室内设计培训学校南京seo招聘
  • WordPress改造成mipseo标题优化关键词
  • 门户网站制作平台江苏网站建站系统哪家好
  • 哪家网站建设服务好新闻内容摘抄
  • 买了个网站后怎么做的nba季后赛最新排名
  • 寺庙招人做网站维护吗公众号推广引流
  • 优良的定制网站建设武汉网站seo
  • 西安网站制作工作室seo优化的主要任务包括
  • 东莞网页制作招聘信息百度seo简爱
  • 最新网站建设方案最有效的广告宣传方式
  • 网站的外部链接怎么做品牌策划方案模板
  • 横峰网站建设汕头seo网站建设
  • 帝国做网站互联网
  • wordpress ip_hash失效常用的seo查询工具