package test;
import java.io.Reader;
import com.ibatis.sqlmap.client.*;
import com.ibatis.common.resources.*;
import bo.*;
public class AutoMag {
private Reader reader;
private SqlMapClient sqlMap;
private String resource = "SqlMapConfig.xml";
public void insertPeople() throws Exception{
try{
reader = Resources.getResourceAsReader(resource);
sqlMap=SqlMapClientBuilder.buildSqlMapClient(reader);
sqlMap.startTransaction();
People people=new People();
people.setName("张三");
people.setAddress("中国");
sqlMap.insert("insertPeople",people);
AutoInfo autoInfo=new AutoInfo();
autoInfo.setLicensePlate("A00001");
autoInfo.setOwnerNo(people);
sqlMap.insert("insertAutoInfo",autoInfo);
sqlMap.commitTransaction();
}finally{
sqlMap.endTransaction();
}
}
}
package test;
import java.io.Reader;
import com.ibatis.sqlmap.client.*;
import com.ibatis.common.resources.*;
import bo.*;
public class AutoMag {
private Reader reader;
private SqlMapClient sqlMap;
private String resource = "SqlMapConfig.xml";
public void insertPeople() throws Exception{
try{
reader = Resources.getResourceAsReader(resource);
sqlMap=SqlMapClientBuilder.buildSqlMapClient(reader);
sqlMap.startTransaction();
People people=new People();
people.setName("张三");
people.setAddress("中国");
sqlMap.insert("insertPeople",people);
AutoInfo autoInfo=new AutoInfo();
autoInfo.setLicensePlate("A00001");
autoInfo.setOwnerNo(people);
sqlMap.insert("insertAutoInfo",autoInfo);
sqlMap.commitTransaction();
}finally{
sqlMap.endTransaction();
}
}
}