ibatis基礎(一):準備ibatis環境

來源:互聯網
上載者:User

iBatis是apache得一個開源項目,一個O/R Mapping解決方案,iBatis的最大特點是小巧,上手很快。如果不需要太多複雜的功能,iBatis是能滿足你的要求並且靈活簡單的方案,官網:http://ibatis.apache.org

搭建環境:匯入相關的jar包

1.匯入資料庫jar包

2.匯入ibatis的jar包

設定檔:

1.JDBC串連的屬性檔案 SqlMap.properties:

driver=org.gjt.mm.mysql.Driver
url=jdbc:mysql://localhost:3306/hibernate
username=root
password=java

2.總設定檔  SqlMapConfig.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="SqlMap.properties"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${username}"/>
<property name="JDBC.Password" value="${password}"/>
</dataSource>
</transactionManager>
<sqlMap resource="com/jim/bean/Student.xml"/>
</sqlMapConfig>

3.關於每個實體的對應檔(map檔案) Student.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap>
……
</sqlMap>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.