对JDBC进行了封装
Dao层去进行数据交互的
轻松操作数据库
1.引入jar包
(2)MySQL -connector-java这是MySQL驱动的依赖
(3) spring jdbc
(4)spring-orm
(5)spring-tx
2.需要druid数据库连接池 加mySQL驱动加JDBC
Springtx对事物进行操作
springorm spring整合框架需要用到的依赖
配置好数据库连接池
2.配置JDBCTemplate对象,注入DateSource
这是一个完整的攻略
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!--数据库连接池-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="url" value="jdbc:mysql://localhost:3306/student?useSSL=false&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT"> </property>
<property name="username" value="root"> </property>
<property name="password" value="root"> </property>
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"> </property>
</bean>
<!--生成JDBC对象-->
<bean id="jdbcTemplate" class=