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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
   <!-- Initialization for data source -->
   <bean />
   </bean>
   <!-- Definition for studentJDBCTemplate bean -->
   <bean />   
   </bean>
</beans>
javaDAO层获取以及使用
 private DataSource ds;
 private JdbcTemplate jdbc;
 
 public DataSource getDs() {
  return ds;
 }
 @Override
 public void setDataSource(DataSource ds) {
  this.ds = ds;
  this.jdbc = new JdbcTemplate(ds);
 }
 @Override
 public void create(String name, String password) {
 String sql = "insert into t_user (username, password) values (?, ?)";    
 jdbc.update( sql, name, password);
  System.out.println("Created Record Name = " + name + " Age = " + password);
 }
 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-05-28
  • 2021-10-01
  • 2022-12-23
  • 2021-08-21
猜你喜欢
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-10-03
相关资源
相似解决方案