Analysis of how to carry out iBATIS SQLMap API programming
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.