Get the App
SLTechnology News&Howtos  ›  Development  › 

Analysis of how to carry out iBATIS SQLMap API programming

Shulou Source: shulou.com Published: 2022-06-02 06:04:35 09月26日 Update

How to carry out iBATIS SQLMap API programming analysis, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.

First of all, after we configure the sqlmap-config.xml file, we need to parse it, for example:

Java code for iBATIS SQLMap

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("Data insertion successful"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block System.out.println("PK"+p.getId()+"Conflict! Unable to insert data "); }finally{ try { sqlMap.endTransaction(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }

iBATIS SQLMap API Programming Batch:

Java code

sqlMap.startBatch(); //... execute statements in between sqlMap.executeBatch(); Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Tags: Programming code data help clarity success content for this documents articles novices more knowledge industry information information channels problems requirements channels into one Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Huawei OPPO Reno Redmi