画布 1
JdbcTemplate
  Maven坐标
    <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.0</version>
</dependency>
    <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.10</version>
</dependency>
  spring依赖注入配置(pom.xml)
    <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 驱动 -->
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<!-- 数据库 jdbc:mysql://ip:port/database -->
<property name="url" value="jdbc:mysql://171.32.1.61:3306/datadb?useUnicode=true&characterEncoding=utf-8"/>
<!-- 用户名 -->
<property name="username" value="test"/>
<!-- 密码 -->
<property name="password" value="test" />
</bean>
<!-- 配置spring jdbctemplate -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
  测试代码
    @Test
public void shouldAnswerWithTrue()
{
ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
JdbcTemplate jdbcTemplate = (JdbcTemplate) app.getBean("jdbcTemplate");
String sql = "select * from Userinfo";
List<Userinfo> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Userinfo>(Userinfo.class));
}
    执行语句讲解
      jdbcTemplate.update(sql, 1300.00, 5) //增，删，改
      jdbcTemplate.queryForObject(sql, Double.class); //返回double对象
      jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(xxxx.class), 5); //封装单条数据为xxx对象
      jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(xxx.class), 4000); //封装多条查询数据结果，返回为list集合，list中为xxx对象