使用abator配置iBatis,管理数据库(以MySql为例)
来源:互联网 发布:中国网络舆情指数 iri 编辑:程序博客网 时间:2024/04/29 09:33
相信很多的朋友对使用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/abatorPress 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" type="post"/> </table><table schema="anquanxitong" tableName="user_info"><generatedKey column="id" sqlStatement="MYSQL" identity="true" type="post"/> </table><table schema="anquanxitong" tableName="user_sta"><generatedKey column="user_id" sqlStatement="MYSQL" identity="true" type="post"/> </table></abatorContext></abatorConfiguration>
4、右键单击配置文件,点击Generate iBatis Artifacts,生成文件。下面是生成后的项目文件。
- 使用abator配置iBatis,管理数据库(以MySql为例)
- 使用abator配置iBatis,管理数据库(以MySql为例)
- ibatis分页(以mysql为例)
- Ibatis Abator
- 使用Abator生成iBatis代码框架
- ibatis代码生成工具abator使用全过程
- Abator 生成 Ibatis 代码使用规范
- MyEclipse中配置MyEclipse Database Explorer 方法(以mysql 数据库为例)
- 配置log4j配置数据库连接池(以dbcp连接池为例),并将log信息存储在数据库中(以mysql为例)
- 【工具使用】MySQL的安装及环境变量配置(以windows10为例)
- MyEclipse连接打开数据库(以mysql为例)
- 数据库中的连接(以mysql为例)
- pandas和数据库进行交互(以mysql为例)
- QT-数据库操作(以MYSQL为例)
- Qt 读取数据库配置文件类(以MySQL为例)
- 数据库中视图相关(以mysql为例)
- 数据库触发器相关(以mysql为例)
- 数据库事件相关(以MYSQL为例)
- varnish+nging与squid+apache缓存
- 计算机专业词汇1
- UIView的layoutSubviews和drawRect方法何时调用
- 突破 Sql 防注入过滤程序继续注入的一点方法、经验、技巧总结
- Unity3d IO流(3)之XML研究
- 使用abator配置iBatis,管理数据库(以MySql为例)
- MFC对话窗口置顶
- 顺序表的简单实现(Java)
- Java谜题3——循环谜题
- hibernate 自动生成数据库表
- eclipse--修改快捷键--代码提示快捷键Content Assist(Alt+/)
- 【STL深入学习】SGI STL空间配置器详解(二)-第二级空间配置器
- 精讲基于oracle的全文索引
- Junit学习笔记1---起步,探索和一个controller实例