首页 > 代码库 > mybatis源码数据库链接配置
mybatis源码数据库链接配置
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
<configuration>
<!-- 数据库连接 -->
<environments default="environment">
<environment id="environment">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="http://www.mamicode.com/com.mysql.jdbc.Driver"/>
<property name="url" value="http://www.mamicode.com/jdbc:mysql://localhost:3306/test"/>
<property name="username" value="http://www.mamicode.com/root"/>
<property name="password" value="http://www.mamicode.com/root"/>
<property name="driver.unicode" value="http://www.mamicode.com/true"/>
<property name="driver.encode" value="http://www.mamicode.com/gbk"/>
</dataSource>
</environment>
</environments>
<!--Oracle配置-->
<!--Oracle配置 <environments default="environment">
<environment id="environment">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver"
value="http://www.mamicode.com/oracle.jdbc.OracleDriver" />
<property name="url"
value="http://www.mamicode.com/jdbc:oracle:thin:@localhost:1521:orcl"/>
<property name="username" value="http://www.mamicode.com/root" />
<property name="password" value="http://www.mamicode.com/root" />
</dataSource>
</environment>
</environments> -->
<mappers>
<mapper resource="com/wf/sql/UserInfoMapper.xml" />
</mappers>
</configuration>
注:数据库链接配置主要是drive和url配置有点区别
需要的包:mybatis-3.2.5.jar,ojdbc6.jar和数据库的驱动包
mybatis源码数据库链接配置