连接池:
????????我们在实际开发中都会使用连接池,因为它可以减少我们获取连接所消耗的时间。

Mybatis中的连接池:
mybatis连接池提供了3种方式的配置: 配置的位置: ? ? ? ?主配置文件SqlMapConfig.xml中的dataSource标签,type属性就是表示采用何种连接池方式。
type属性的取值:? ????????POOLED:采用传统的javax.sql.DataSource规范中的连接池,mybatis中有针对规范的实现 ????????UNPOOLED:采用传统的获取连接的方式,虽然也实现Javax.sql.DataSource接口,但是并没有使用池的思想。?? ????????JNDI:采用服务器提供的JNDI技术实现,来获取DataSource对象,不同的服务器所能拿到的DataSource是不一样的。 注意:如果不是web或者maven的war工程,是不能使用的。 我们使用的是tomcat服务器,采用连接池就是dbcp连接池。
??POOLED配置连接池的原理:
mybatis中的事务
什么是事务 事务的四大特性ACID 不考虑隔离性会产生的3个问题 解决办法:四种隔离级别
它是通过sqlsession对象的commit方法和rollback方法实现事务的提交和回滚
Mybatis自动提交事务的设置: crud过程中必须使用sqlSession.commit()提交事务,主要原因就是在连接池中取出的连接,都会将调用connection.setAutoCommit(false)方法,这样我们就必须使用sqlSession.commit()方法,相当于使用了JDBC中的connection.commit()方法实现事务提交。

自动提交:


mybatis中的动态sql语句:
if标签

where标签

foreach标签:

?(item中的名字和#中保持一致)
抽取重复的sql语句:

|