参考:
http://blog.csdn.net/watson243671/archive/2010/01/02/5122385.aspx
帮助文档:
http://ibatis.apache.org/docs/tools/abator/
相信很多的朋友对使用iBatis管理数据库很不习惯,因为我们要手写代码,特别是dynamic query部分更是不知如何嵌套,而这些是可以用工具的!下面介绍一种最常用的!不废话了,直接上配置过程!
1、获得 http://ibatis.apache.org/abator.html
Eclipse可以自动的进行Update获取此Plugin,官方的安装步骤.
If you've already installed a prior version of Abator, simply run the Eclipse Install/Update tool and the new version will be found automatically.
If you've not already installed Abator, then you can use the built in Eclipse install support by following these steps:
Take the "Help>Software Updates>Find and Install" Menu Option
Select the "Search for new features to install" radio button, press "Next"
Press the "New Remote Site" button
Enter the following information:
Name:
Abator for Eclipse Update Site
URL:
http://ibatis.apache.org/tools/abator
Press OK
Check the box next to "Abator for Eclipse Update Site"
Follow the remainder of the install wizard
2、安装好后将在New菜单中看到一个新的文件类型Abator for iBATIS Configuration File,此是Abator的配置文件,配置文件的详细说明见http://ibatis.apache.org/docs/tools/abator/
3、新建一个配置文件,进行修改,根据自己的实际需求进行修改
关键点:
1)jdbc connection,按照一般的配置即可,需要说明的是它需要指定访问JdbcDriver的classPathEntry,对于MsSqlServer而言,要将这三个jar文件均包含在内,否则会出现jdbc访问错误。
2)配置三个Pakage
3)配置表,此处需说明的是对于MsSqlServer不能写TableSchema,我初次指定TableSchema,结果未找到对应的表
简单的配置如下,复杂的见配置文件的详细说明。示例配置文件如下 :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
"http://ibatis.apache.org/dtd/abator-config_1_0.dtd">
<abatorConfiguration>
<abatorContext generatorSet="Java5">
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/anquanxitong"
userId="root" password="123456">
<classPathEntry location="C:\Documents and Settings\Administrator\Workspaces\MyEclipse\iBatisMysql\lib\mysql-connector-java-5.1.10-bin.jar" />
</jdbcConnection>
<javaModelGenerator targetPackage="com.agile.aqxt.model" targetProject="iBatisMysql" />
<sqlMapGenerator targetPackage="com.agile.aqxt.maps" targetProject="iBatisMysql" />
<daoGenerator targetPackage="com.agile.aqxt.dao" targetProject="iBatisMysql" type="GENERIC-SI" />
<table schema="anquanxitong" tableName="card_info">
<generatedKey column="card_id" sqlStatement="MYSQL" identity="true" />
</table>
<table schema="anquanxitong" tableName="user_info">
<generatedKey column="id" sqlStatement="MYSQL" identity="true" />
</table>
<table schema="anquanxitong" tableName="user_sta">
<generatedKey column="user_id" sqlStatement="MYSQL" identity="true" />
</table>
</abatorContext>
</abatorConfiguration>
4、右键单击配置文件,点击Generate iBatis Artifacts,生成文件。下面是生成后的项目文件。
分享到:
相关推荐
Ibatis数据库操作,JGP上传到数据库
非常适合初学入门的例子 Abator+ibatis
1.每个实体类需要配置各自的“SqlMap.config”在“config/SysConfig.xml”中,SqlMap,db1.Db1SqlMap就是“ibatis/db1/Db1SqlMap.config”,不同的db将分配不同的mapper类。 2.数据库链接统一放在“config/ibatis/...
NULL 博文链接:https://qiuqiu0034.iteye.com/blog/1155067
本工程用于研究Ibatis和MySQL结合使用的方法 本工程编码方式:UTF-8 须执行的SQL语句: CREATE DATABASE `test`; USE `test`; DROP TABLE IF EXISTS `student`; CREATE TABLE `student` ( `id` char(36) NOT NULL...
C#中iBatis连接mySQL使用的DLL
Ibatis连接ORACLE数据库的小例子
描述与iBatis相关技术与数据库进行增删改查操作
Ibatis连接MySQL数据库实例 有代码 项目下下来直接跑就行了,不过要修改数据库配置信息哦 跑不起来我吃翔三斤
使用Struts1.2+IBatis对数据库表进行增、删、改、查操作; 有清晰的案例使用说明,完整的案例, 直接可以附加看效果。 案例作者:宋海康
在用iBatis.net与数据库打交道的过程中,发现iBatis.net拼接字符串不能直接拷贝然后在dbms里执行
Abator自动生成ibatis代码!
基于iBATIS的数据库访问技术及其web应用,封小钰,王飞,介绍了通过IBATIS访问数据库的方法,建立了通过IBATIS完成对数据库访问配置、实现数据库访问控制的系统。在数据持久层使用IBATIS作为Jav
Ibatis 2.3.4 数据库无关分页 有示例,可以运行 网上找的很不错
操作数据库 iBATIS查询,java 和spring的配置方法
IBATIS连接多数据库参考文档,只供参考,学习。
使用ibatis操作大对象,使用mySQl数据库对图片进行操作
运用IBATIS在三层架构的基础上建立的数据库连接,主要是一个框架,突出重点,一看就明白。最适合初学者快速学习使用,里面的条路清晰。
模仿电影购票写的一个宾馆订房的小例子,主要功能有登录,注册,下载图片(没有使用缓存之类),...服务器用servlet+ibatiS写的(只为android提供了数据接口,没有为pc写界面)(数据库密码默认是sa),数据库用mysql。
本工程以“银行账号转账”为例子演示了 如何处理Ibatis结合MySQL数据库使用时的事务操作 本工程编码方式:UTF-8 须执行的SQL语句: CREATE DATABASE `test`; USE `test`; CREATE TABLE `lm_bank_card` ( `id` ...