iBATIS SQLMap API编程浅析
iBATIS SQLMap API编程如何进行呢?首先我们配置好sqlmap-config.xml文件以后,需要对他进行解析,例如:
iBATIS SQLMap的Java代码
public void insert(Person p){ String xml = "com/Jdnis/ibatis/map/sql-map-config.xml"; SqlMapClient sqlMap = null; try { Reader reader = Resources.getResourceAsReader(xml); sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); sqlMap.startTransaction(); sqlMap.insert("insertPerson",p); sqlMap.commitTransaction(); System.out.println("数据插入成功"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block System.out.println("主键 "+p.getId()+" 冲突!无法插入数据"); }finally{ try { sqlMap.endTransaction(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
iBATIS SQLMap API编程批处理:
Java代码
相关推荐
zyjj 2020-07-04
bluet00 2020-06-25
godfather 2020-06-13
lt云飞扬gt 2020-06-09
旗木卡卡西 2020-06-02
徐悦TechBlog 2020-05-27
liuyang000 2020-03-05
xuanlvhaoshao 2020-02-21
ItBJLan 2020-02-20
tanrong 2020-02-15
gwn00 2020-02-01
一对儿程序猿 2020-01-18
xuanlvhaoshao 2020-01-02
gwn00 2020-01-09
tanrong 2019-12-22
tanrong 2019-12-16
一对儿程序猿 2019-11-10