spring jdbcTemplate使用

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: (1)springJdbcContext.xml  Java代码                springApp                      ...
(1)springJdbcContext.xml 
Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"   
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xmlns:context="http://www.springframework.org/schema/context"   
  5.     xmlns:aop="http://www.springframework.org/schema/aop"   
  6.     xmlns:tx="http://www.springframework.org/schema/tx"   
  7.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  8.     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd   
  9.     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd   
  10.     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
  11.   
  12.     <description>springApp</description>      
  13.     <!-- dataSource for MySQL -->  
  14.     <bean id="dataSource"  
  15.         class="org.apache.commons.dbcp.BasicDataSource"  
  16.         destroy-method="close">  
  17.         <property name="driverClassName"  
  18.             value="com.mysql.jdbc.Driver" />  
  19.         <property name="url"  
  20.             value="jdbc:mysql://localhost:3306/springapp" />  
  21.         <property name="username" value="root" />  
  22.         <property name="password" value="****" />  
  23.     </bean>     
  24.   
  25.     <bean id = "TransactionManager"   
  26.          class = "org.springframework.jdbc.datasource.DataSourceTransactionManager">   
  27.          <property name = "dataSource" ref="dataSource"/>   
  28.     </bean>  
  29.       
  30.     <!--1:配置一个JdbcTemplate实例,并将这个“共享的”,“安全的”实例注入到不同的DAO类中去-->  
  31.     <bean id = "jdbcTemplate"   
  32.          class = "org.springframework.jdbc.core.JdbcTemplate">   
  33.          <property name = "dataSource" ref="dataSource"/>   
  34.     </bean>  
  35.   
  36.     <bean id = "actorJdbcTemplateDao"   
  37.          class = "com.logcd.bo.dao.impl.ActorJdbcTemplateDaoImpl">   
  38.          <property name="jdbcTemplate" ref="jdbcTemplate"/>   
  39.     </bean>  
  40.       
  41.     <!--2:将共享的DataSource实例注入到DAO中,JdbcTemplate实例在DataSource的setter方法中被创建-->  
  42.     <bean id = "actorEventDao"   
  43.          class = "com.logcd.bo.dao.impl.ActorEventDaoImpl">   
  44.          <property name = "dataSource" ref="dataSource"/>   
  45.     </bean>  
  46.   
  47.     <!--利用了拦截器的原理。-->     
  48.    <bean id="transactionInterceptor"    
  49.          class="org.springframework.transaction.interceptor.TransactionInterceptor">     
  50.         <property name="transactionManager">      
  51.                   <ref bean="transactionManager" />     
  52.         </property>     
  53.     <!-- 配置事务属性 -->  
  54.    <property name="transactionAttributes">     
  55.         <props>     
  56.             <prop key="delete*">PROPAGATION_REQUIRED</prop>  
  57.             <prop key="operate*">PROPAGATION_REQUIRED,-Exception</prop>     
  58.             <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>     
  59.             <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>     
  60.             <prop key="save*">PROPAGATION_REQUIRED</prop>     
  61.             <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>     
  62.        </props>     
  63.    </property>     
  64.    </bean>     
  65.    <bean id="txProxy"    
  66.          class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">     
  67.         <property name="beanNames">     
  68.           <list>     
  69.              <value>*Dao*</value><!--只是为了测试,一般为service-->  
  70.           </list>     
  71.         </property>     
  72.         <property name="interceptorNames">     
  73.           <list>     
  74.              <value>transactionInterceptor</value>     
  75.           </list>     
  76.         </property>     
  77.    </bean>    
  78.   
  79. </beans>  

(2)接口:(以第二种方式定义DAO) 
Java代码   收藏代码
  1. package com.logcd.bo.dao;  
  2.   
  3. import java.util.List;  
  4.   
  5. import org.springframework.jdbc.support.KeyHolder;  
  6.   
  7. import com.logcd.bo.Actor;  
  8.   
  9. public interface ActorEventDao {  
  10.     /** 
  11.      * 根据SQL建表 
  12.      * @param sql 
  13.      */  
  14.     public void createTableBySQL(String sql);  
  15.   
  16.     /** 
  17.      * 统计firstName相同的总数 
  18.      * @param firstName 
  19.      * @return 
  20.      */  
  21.     public int findCountOfActorsByFirstName(String firstName);  
  22.   
  23.     /** 
  24.      * 插入记录并返回自动生成的主键Id 
  25.      * @param ps 
  26.      * @return 
  27.      */  
  28.     public KeyHolder insertActor(final Actor actor);  
  29.   
  30.     /** 
  31.      * 用SimpleJdbcInsert插入一条记录:mysql测试成功 
  32.      */  
  33.     public long inserOneActor(Actor actor);  
  34.       
  35.     /** 
  36.      * 插入/更新/删除数据 
  37.      * @param sql 有参数语句 
  38.      * @param obj 参数值数组 
  39.      */  
  40.     public int operateActor(String sql,Object[] obj);  
  41.   
  42.     /** 
  43.      * 根据SQL查询记录总数 
  44.      * @param sql 
  45.      * @return 
  46.      */  
  47.     public int findRowCountBySQL(String sql);  
  48.   
  49.     /** 
  50.      * 根据Id查找指定对象 
  51.      * @param id 
  52.      * @return 
  53.      */  
  54.     public Actor findActorById(long id);  
  55.   
  56.     /** 
  57.      * 根据Id查找指定对象 
  58.      * @param id 
  59.      * @return 
  60.      */  
  61.     public Actor findActorByIdSimple(long id);  
  62.   
  63.     /** 
  64.      * 返回所有对象 
  65.      * @return 
  66.      */  
  67.     public List findAllActors();  
  68.   
  69.             /** 
  70.      * 批量更新 
  71.      * @param actors 
  72.      * @return 
  73.      */  
  74.     public int[] updateBatchActors(final List actors);  
  75.   
  76.     /** 
  77.      * 批量更新 
  78.      * @param actors 
  79.      * @return 
  80.      */  
  81.     public int[] updateBatchActorsSimple(final List<Actor> actors);  
  82.   
  83. }  

(3)接口实现 
Java代码   收藏代码
  1. package com.logcd.bo.dao.impl;  
  2.   
  3. import java.sql.Connection;  
  4. import java.sql.PreparedStatement;  
  5. import java.sql.ResultSet;  
  6. import java.sql.SQLException;  
  7. import java.util.List;  
  8.   
  9. import javax.sql.DataSource;  
  10.   
  11. import org.springframework.jdbc.core.JdbcTemplate;  
  12. import org.springframework.jdbc.core.PreparedStatementCreator;  
  13. import org.springframework.jdbc.core.RowMapper;  
  14. import org.springframework.jdbc.support.GeneratedKeyHolder;  
  15. import org.springframework.jdbc.support.KeyHolder;  
  16.   
  17. import com.logcd.bo.Actor;  
  18. import com.logcd.bo.dao.ActorEventDao;  
  19.   
  20. public class ActorEventDaoImpl implements ActorEventDao{  
  21.       
  22.     private JdbcTemplate jdbcTemplate;  
  23.       
  24.     //NamedParameterJdbcTemplate对JdbcTemplate封装,增加了命名参数特性  
  25.     private NamedParameterJdbcTemplate namedParameterJdbcTemplate;  
  26.   
  27.     //SimpleJdbcTemplate对JdbcTemplate封装,某些特性要在java5以上才工作  
  28.     private SimpleJdbcTemplate simpleJdbcTemplate;  
  29.       
  30.     //简化插入数据操作  
  31.     private SimpleJdbcInsert inserActor;  
  32.       
  33.     public void setDataSource(DataSource dataSource){  
  34.         this.jdbcTemplate = new JdbcTemplate(dataSource);  
  35.         this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);  
  36.         this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);  
  37.         this.inserActor = new SimpleJdbcInsert(dataSource)  
  38.         .withTableName("actors")  
  39.         .usingColumns("first_name","last_name")//插入这些字段  
  40.         .usingGeneratedKeyColumns("id");//带回生成的id  
  41.     }  
  42.   
  43.     /** 
  44.      * 用SimpleJdbcInsert插入一条记录 
  45.      */  
  46.     public long inserOneActor(Actor actor){  
  47.         Map<String,Object> parameters = new HashMap<String,Object>();  
  48.         parameters.put("first_name",actor.getFirstName());  
  49.         parameters.put("last_name",actor.getLastName());  
  50.         return inserActor.executeAndReturnKey(parameters).longValue();  
  51.     }  
  52.       
  53.     /** 
  54.      * 统计firstName相同的总数 
  55.      * @param firstName 
  56.      * @return 
  57.      */  
  58.     public int findCountOfActorsByFirstName(String firstName){  
  59.         String sql="select count(0) from actors where first_name = :first_name";  
  60.         SqlParameterSource namedParameters = new MapSqlParameterSource("first_name",firstName);  
  61.         //Map namedParameter = Collections.singletonMap("first_name",firstName);  
  62.         //还有一种Bean封装的方式  
  63.         //SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(exampleActor);  
  64.         return this.namedParameterJdbcTemplate.queryForInt(sql, namedParameters);  
  65.     }  
  66.   
  67.     /** 
  68.      * 根据SQL建表 
  69.      * @param sql 
  70.      */  
  71.     public void createTableBySQL(String sql) {  
  72.         this.jdbcTemplate.execute(sql);  
  73.     }  
  74.       
  75.     /** 
  76.      * 插入记录并返回自动生成的主键Id(MySQL中不行,Oracle可以) 
  77.      * @param ps 
  78.      * @return 
  79.      */  
  80.     public KeyHolder insertActor(final Actor actor){  
  81.         final String addSql = "insert into actors(first_name,last_name) values (?,?)";  
  82.         KeyHolder keyHolder = new GeneratedKeyHolder();  
  83.         this.jdbcTemplate.update(new PreparedStatementCreator(){  
  84.             public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {  
  85.                 PreparedStatement ps =  
  86.                     conn.prepareStatement(addSql, new String[]{"id"});//返回id  
  87.                 ps.setString(1, actor.getFirstName());  
  88.                 ps.setString(2, actor.getLastName());  
  89.                 return ps;  
  90.             }  
  91.               
  92.         });  
  93.         System.out.println(keyHolder.getKey());  
  94.         return keyHolder;  
  95.     }  
  96.       
  97.     /** 
  98.      * 插入/更新/删除数据 
  99.      * @param sql 有参数语句 
  100.      * @param obj 参数值数组 
  101.      */  
  102.     public int operateActor(String sql,Object[] obj){  
  103.         return this.jdbcTemplate.update(sql, obj);  
  104.     }  
  105.   
  106.     /** 
  107.      * 根据SQL查询记录总数 
  108.      * @param sql 
  109.      * @return 
  110.      */  
  111.     public int findRowCountBySQL(String sql){  
  112.         return this.jdbcTemplate.queryForInt(sql);  
  113.     }  
  114.       
  115.     /** 
  116.      * 根据Id查找指定对象 
  117.      * @param id 
  118.      * @return 
  119.      */  
  120.     public Actor findActorById(long id){  
  121.         Actor actor = (Actor) this.jdbcTemplate.queryForObject(  
  122.                 "select id,first_name,last_name from actors where id = ?",  
  123.                 new Object[]{new Long(id)},   
  124.                 new RowMapper(){  
  125.   
  126.                     public Object mapRow(ResultSet rs, int rowNum) throws SQLException {  
  127.                         Actor act = new Actor();  
  128.                         act.setId(rs.getLong("id"));  
  129.                         act.setFirstName(rs.getString("first_name"));  
  130.                         act.setLastName(rs.getString("last_Name"));  
  131.                         return act;  
  132.                     }  
  133.                       
  134.                 });  
  135.         return actor;  
  136.     }  
  137.   
  138.   
  139.     /** 
  140.      * 根据Id查找指定对象 
  141.      * @param id 
  142.      * @return 
  143.      */  
  144.     public Actor findActorByIdSimple(long id){  
  145.         String sql = "select id,first_name,last_name from actors where id = ?";  
  146.           
  147.         ParameterizedRowMapper<Actor> mapper = new ParameterizedRowMapper<Actor>(){  
  148.             //notice the return type with respect to java 5 covariant return types  
  149.             public Actor mapRow(ResultSet rs, int rowNum) throws SQLException {  
  150.                 Actor act = new Actor();  
  151.                 act.setId(rs.getLong("id"));  
  152.                 act.setFirstName(rs.getString("first_name"));  
  153.                 act.setLastName(rs.getString("last_Name"));  
  154.                 return act;  
  155.             }  
  156.         };  
  157.           
  158.         return this.simpleJdbcTemplate.queryForObject(sql, mapper, id);  
  159.     }  
  160.       
  161.     /** 
  162.      * 返回所有对象 
  163.      * @return 
  164.      */  
  165.     public List findAllActors(){  
  166.         return this.jdbcTemplate.query(  
  167.                 "select id,first_name,last_name from actors",  
  168.                 new ActorMapper());  
  169.     }  
  170.       
  171.     /** 
  172.      * 定义一个静态内部类,在Dao的方法中被共享 
  173.      * @author logcd 
  174.      */  
  175.     private static final class ActorMapper implements RowMapper{  
  176.   
  177.         public Object mapRow(ResultSet rs, int rowNum) throws SQLException {  
  178.             Actor act = new Actor();  
  179.             act.setId(rs.getLong("id"));  
  180.             act.setFirstName(rs.getString("first_name"));  
  181.             act.setLastName(rs.getString("last_Name"));  
  182.             return act;  
  183.         }  
  184.           
  185.     }  
  186. }  
  187.   
  188.     /** 
  189.      * 批量更新 
  190.      * @param actors 
  191.      * @return 
  192.      */  
  193.     public int[] updateBatchActors(final List actors){  
  194.         int[] updateCounts =this.jdbcTemplate.batchUpdate(  
  195.                 "update actors set first_name = ?, last_name = ? where id =? ",   
  196.                 new BatchPreparedStatementSetter(){  
  197.   
  198.                     public int getBatchSize() {  
  199.                         return actors.size();  
  200.                     }  
  201.   
  202.                     public void setValues(PreparedStatement ps, int i) throws SQLException {  
  203.                         ps.setString(1, ((Actor)actors.get(i)).getFirstName());  
  204.                         ps.setString(2, ((Actor)actors.get(i)).getLastName());  
  205.                         ps.setLong(3, ((Actor)actors.get(i)).getId());  
  206.                     }  
  207.                       
  208.                 });  
  209.         return updateCounts;  
  210.     }  
  211.   
  212.     /** 
  213.      * 批量更新 
  214.      * @param actors 
  215.      * @return 
  216.      */  
  217.     public int[] updateBatchActorsSimple(final List<Actor> actors){  
  218.         //如果对象数组与占位符出现位置一一对应  
  219.         //SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(actors.toArray());  
  220.         List<Object[]> batch = new ArrayList<Object[]>();  
  221.         for(Actor actor:actors){  
  222.             Object[] values = new Object[]{//注意顺序  
  223.                     actor.getFirstName(),  
  224.                     actor.getLastName(),  
  225.                     actor.getId()};  
  226.             batch.add(values);  
  227.         }  
  228.         int[] updateCounts = this.simpleJdbcTemplate.batchUpdate(  
  229.                 "update actors set first_name = ?, last_name = ? where id =? ",  
  230.                 batch);  
  231.         return updateCounts;  
  232.     }  

(4)测试 
Java代码   收藏代码
  1. /** 
  2.  *  
  3.  */  
  4. package com.logcd.test;  
  5.   
  6. import org.springframework.context.ApplicationContext;  
  7. import org.springframework.context.support.ClassPathXmlApplicationContext;  
  8. import org.springframework.jdbc.support.KeyHolder;  
  9.   
  10. import com.logcd.bo.Actor;  
  11. import com.logcd.bo.dao.ActorEventDao;  
  12. import com.logcd.bo.dao.ActorJdbcTemplateDao;  
  13.   
  14. import junit.framework.TestCase;  
  15.   
  16. /** 
  17.  * @author logcd 
  18.  */  
  19. public class SpringJdbcTest extends TestCase {  
  20.   
  21.     private ActorEventDao actorEventDao;   
  22.     private ActorJdbcTemplateDao actorJdbcTemplateDao;  
  23.       
  24.     protected void setUp() throws Exception {  
  25.         super.setUp();  
  26.         ApplicationContext context = new ClassPathXmlApplicationContext("springJdbcContext.xml");  
  27.         actorEventDao = (ActorEventDao)context.getBean("actorEventDao");  
  28.         actorJdbcTemplateDao = (ActorJdbcTemplateDao)context.getBean("actorJdbcTemplateDao");  
  29.     }  
  30.   
  31.     protected void tearDown() throws Exception {  
  32.         super.tearDown();  
  33.     }  
  34.   
  35.     public void testActorEventDao(){  
  36.         String creatSql = "create table ACTORS(" +  
  37.         "ID int not null auto_increment," +  
  38.         "FIRST_NAME varchar(15)," +  
  39.         "LAST_NAME varchar(15)," +  
  40.         "primary key (ID)" +  
  41.         ");" ;  
  42.         //建表  
  43.         actorEventDao.createTableBySQL(creatSql);  
  44.           
  45.         String addSql = "insert into actors(first_name,last_name) values(?,?);";  
  46.         Object[] obj = new Object[]{"wang","jinming"};  
  47.         //新增  
  48.         System.out.println(actorEventDao.operateActor(addSql, obj));  
  49.       
  50.         String countSql = "select count(0) from actors";  
  51.         System.out.println("Count:"+actorEventDao.findRowCountBySQL(countSql));  
  52.         System.out.println("Count:"+actorJdbcTemplateDao.findRowCountBySQL(countSql));  
  53.         //根据id查找  
  54.         Actor actor = actorEventDao.findActorById(1);  
  55.         System.out.println("id:"+actor.getId()+"  first_name:"+actor.getFirstName()+"  last_name:"+actor.getLastName());  
  56.         //输出所有  
  57.         for(Object o:actorEventDao.findAllActors()){  
  58.             Actor act = (Actor) o;  
  59.             System.out.println("id:"+act.getId()+"  first_name:"+act.getFirstName()+"  last_name:"+act.getLastName());  
  60.         }  
  61.           
  62.         Actor newAct=new Actor();  
  63.         newAct.setFirstName("jin");  
  64.         newAct.setLastName("ming");  
  65.         KeyHolder keyHold =actorEventDao.insertActor(newAct);  
  66.         System.out.println(keyHold.getKey());//mysql得不到id  
  67.   
  68.         List<Actor> list = new ArrayList<Actor>();  
  69.         for(Object o:actorEventDao.findAllActors()){  
  70.             Actor act = (Actor) o;  
  71.             System.out.println("id:"+act.getId()+"  first_name:"+act.getFirstName()+"  last_name:"+act.getLastName());  
  72.             act.setLastName("www");  
  73.             list.add(act);  
  74.         }  
  75.         actorEventDao.batchUpdateActors(list);  
  76.         for(Object o:actorEventDao.findAllActors()){  
  77.             Actor act = (Actor) o;  
  78.             System.out.println("id:"+act.getId()+"  first_name:"+act.getFirstName()+"  last_name:"+act.getLastName());  
  79.         }  
  80.     }  
  81. }  

二、关于操作Blob和Clob问题 
     spring定义了一个以统一的方式操作各种数据库的Lob类型数据的LobCreator(保存的时候用),同时提供了一个LobHandler为操作二进制字段和大文本字段提供统一接口访问。 
(1)配置文件 
Xml代码   收藏代码
  1. <bean id="nativeJdbcExtractor"  
  2.  class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"  
  3.       lazy-init="true"/>  
  4.   
  5. <bean id="lobHandler"  
  6.  class="org.springframework.jdbc.support.lob.OracleLobHandler"  
  7.         lazy-init="true"  
  8.         p:nativeJdbcExtractor-ref="nativeJdbcExtractor"/>  
  9.   
  10. <bean id="defaultLobHandler"  
  11.    class="org.springframework.jdbc.support.lob.DefaultLobHandler"  
  12.    lazy-init="true" />  
  13.   
  14. <bean id="jdbcTemplate"  
  15. class="org.springframework.jdbc.core.JdbcTemplate"  
  16.         p:dataSource-ref="appDS"  
  17.         p:nativeJdbcExtractor-ref="nativeJdbcExtractor"/>  
  18.             
  19. <bean id="txMangager"  
  20.  class="org.springframework.jdbc.datasource.DataSourceTransactionManager"  
  21.         p:dataSource-ref="appDS"/>  
  22.   
  23. <tx:annotation-driven transaction-manager="txMangager" proxy-target-class="true"/>  


(2)读写 
Java代码   收藏代码
  1. @Resource(name = "lobHandler")     
  2. private LobHandler lobHandler;     
  3.     
  4. @Resource(name = "jdbcTemplate")     
  5. private  JdbcTemplate jdbcTemplate;     
  6.     
  7. public void savePost(final Post post) {       
  8.    String sql = " INSERT INTO t_post(post_id,user_id,post_text,post_attach)"    
  9.      + " VALUES(?,?,?,?)";     
  10.    jdbcTemplate().execute(sql,     
  11.      new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) {     
  12.          protected void setValues(PreparedStatement ps,     
  13.               LobCreator lobCreator) throws SQLException {     
  14.                   ps.setInt(1, incre.nextIntValue());      
  15.                   ps.setInt(2, post.getUserId());      
  16.                   lobCreator.setClobAsString(ps, 3, post.getPostText());     
  17.                   lobCreator.setBlobAsBytes(ps, 4, post.getPostAttach());     
  18.         }  
  19.      });     
  20. }     
  21.     
  22. public List findAttachs(final int userId){     
  23.    String sql = "SELECT post_id,post_attach FROM t_post where user_id =? and post_attach is not null";     
  24.    return jdbcTemplate().query( sql, new Object[] {userId},     
  25.       new RowMapper() {     
  26.           public Object mapRow(ResultSet rs, int rowNum) throws SQLException {     
  27.           Post post = new Post();     
  28.           int postId = rs.getInt(1);     
  29.           byte[] attach = lobHandler.getBlobAsBytes(rs, 2);     
  30.           post.setPostId(postId);     
  31.           post.setPostAttach(attach);     
  32.           return post;     
  33.       }    
  34.    });    
  35. }    
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
Java Spring
使用JDBCTemplate实现与Spring结合,方法公用 ——测试(EmpDaoImplTest)
使用JDBCTemplate实现与Spring结合,方法公用 ——测试(EmpDaoImplTest)
11 0
|
5月前
|
XML Java 数据库
【Spring】通过JdbcTemplate实现CRUD操作
【Spring】通过JdbcTemplate实现CRUD操作
36 0
|
4月前
|
XML Java 关系型数据库
Spring6 JdbcTemplate和事务
Spring6 JdbcTemplate和事务
|
1月前
|
SQL Java 数据库连接
jpa、hibernate、spring-data-jpa、jdbcTemplate
jpa、hibernate、spring-data-jpa、jdbcTemplate
|
2月前
|
Java Spring
使用JDBCTemplate实现与Spring结合,方法公用 ——Emp实现类(EmpDaoImpl)
使用JDBCTemplate实现与Spring结合,方法公用 ——Emp实现类(EmpDaoImpl)
8 0
|
2月前
|
Java Spring
使用JDBCTemplate实现与Spring结合,方法公用 ——共用实现类(BaseImpl)
使用JDBCTemplate实现与Spring结合,方法公用 ——共用实现类(BaseImpl)
11 1
|
2月前
|
Java Spring
使用JDBCTemplate实现与Spring结合,方法公用 ——接口(BaseDao)
使用JDBCTemplate实现与Spring结合,方法公用 ——接口(BaseDao)
9 0
|
2月前
|
Java Spring
使用JDBCTemplate实现与Spring结合,方法公用
使用JDBCTemplate实现与Spring结合,方法公用
8 0
|
4月前
|
SQL Java 数据库连接
Spring 模板技术JdbcTemplate
Spring 模板技术JdbcTemplate
32 0
Spring 模板技术JdbcTemplate
|
4月前
|
Java 数据库连接 数据库
Spring之JdbcTemplate(带你一篇文章搞定JdbcTemplate)
Spring之JdbcTemplate(带你一篇文章搞定JdbcTemplate)