项目中要解析Xml文件,于是在工程里找了下前人写例子。

1,SAX(基于事件,效率高,使用声明加载什么)。

public class MVCConfig {
private static MVCConfig config=new MVCConfig(); private MVCConfig(){} public static MVCConfig getInstance(){
return config;
} private Map<String, ActionDTO> actions=new HashMap<String, ActionDTO>();
private DataSourceDTO datasourceDto=null; //解析xml文件的方法
public void parse(String path){
//1.产生一个解析器
Digester digester=new Digester();
//2.指出回调函数所属对象
digester.push(this);
//3.声明遇到XXX节点,就调用XXX回调方法
digester.addCallMethod("mvc-config/action-mapping/action", "doAction", 3);
digester.addCallParam("mvc-config/action-mapping/action", 0, "path");
digester.addCallParam("mvc-config/action-mapping/action", 1, "className");
digester.addCallParam("mvc-config/action-mapping/action", 2, "redirect"); digester.addCallMethod("mvc-config/dataSource", "doDataSource",5);
digester.addCallParam("mvc-config/dataSource/driver", 0);
digester.addCallParam("mvc-config/dataSource/url", 1);
digester.addCallParam("mvc-config/dataSource/username", 2);
digester.addCallParam("mvc-config/dataSource/password", 3);
digester.addCallParam("mvc-config/dataSource/maxActive", 4);
//4.真正开始解析
try {
digester.parse(new File(path));
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
} //回调方法(传过来的所有参数类型都是字符串)
public void doAction(String path,String className,String redirect){
//System.out.println(path+" "+className);
ActionDTO dto=new ActionDTO(path,className,Boolean.parseBoolean(redirect));
actions.put(path, dto);
} public void doDataSource(String driver,String url,String username,String password,String maxActive){
//System.out.println(driver);
datasourceDto=new DataSourceDTO(driver,url,username,password,Integer.parseInt(maxActive));
} //测试解析是否成功
public static void main(String[] args) {
MVCConfig.getInstance().parse("D:/mvc-config.xml");
} public Map<String, ActionDTO> getActions() {
return actions;
} public DataSourceDTO getDatasourDto() {
return datasourceDto;
}
}

2,DOM(基于文档/节点,一次加载所有,需要内存大)。项目里例子是零二年写的,代码现在看起来比较渣,先贴出来有时间了再整理整理

public class TjFileService extends ManagerParent {
public TjFileService()
{
} private static final String errorPrefix =
ErrorCodeDefine.EXCEPTION_SYSTEM +
ErrorCodeDefine.MODULE_REGIST +
ErrorCodeDefine.CLASS_REGISTMANAGER; //出错代码前缀
private static final LogicException DB_ERROR =
new LogicExceptionParent(errorPrefix + "02","数据库出错");
public boolean importTjBasefile(String importfilename,String userName, String userId) throws IOException, LogicException, ParseException, SQLException {
Connection conn = null; try{ String xmlPath=null;
try {
conn = getConnection(false);
} catch (SQLException e) { e.printStackTrace();
} SAXReader saxReader = new SAXReader();
Document document =null;
xmlPath=importfilename.replace('\\','/');
document=saxReader.read(new File(xmlPath));
Element root=document.getRootElement();
System.out.println("read ok ,nodes count="+root.elements().size());
List lsttable=root.elements();
// logger.debug("the tables number is "+lsttable.size());
if (! root.getName().equals("RcMarry"))
return false; Iterator itr=lsttable.iterator();
SerialManageManager serialmanage;
SerialManageModel serialManageModel;
serialManageModel=new SerialManageModel();
AcceptOrganModel acceptOrganModel = new AcceptOrganModel();
int j=0;
while (itr.hasNext()){
Element tbelment=(Element)itr.next();
// logger.debug("the table "+tbname+ "'s elements count is"+tbelment.elements().size());
if (tbelment.elements().size()==0)
continue;
Iterator itrrec=tbelment.elementIterator();
Element Firstrec=(Element)tbelment.elements().get(0);
String[] cols = new String[Firstrec.attributeCount()];
int i=0;
for(i=0;i<Firstrec.attributeCount();i++){
Attribute attr=(Attribute)Firstrec.attributes().get(i);
cols[i]=attr.getName();
}
//开始读取XML文件
while(itrrec.hasNext())
{
Element recelement=(Element)itrrec.next();
final String colval[]=new String[cols.length];
final String colname[]=new String[cols.length];
// String certNum = getCertId(recelement
// .attribute("CERT_NO").getValue());
String certNum = "";
if (recelement.attribute("CERT_NO")==null)
certNum = "";
else
certNum = recelement
.attribute("CERT_NO").getValue();
String OldcertNum = "";
if (recelement.attribute("OLD_CERT_NO")==null)
OldcertNum = "";
else
OldcertNum = recelement
.attribute("OLD_CERT_NO").getValue(); //根据recelement 拼装 MarryAppModel
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String todate = "";
String op_type = recelement.attribute("OP_TYPE").getValue();
MarryAppModel marryAppModel = new MarryAppModel();
SerialManageDAO dao = new SerialManageDAO(conn); marryAppModel.setAccpt_organ("000310999");
marryAppModel.setBespeak_no(null);
//登记人员信息
if(recelement.attribute("OPERATOR")==null || "".equals(recelement.attribute("OPERATOR").getValue())){
marryAppModel.setReg_person(null);
}else{
String operator=recelement.attribute("OPERATOR").getValue();
marryAppModel.setReg_person(operator);
TjFileDAO tjFileDAO=new TjFileDAO(conn);
marryAppModel.setReg_person_id(tjFileDAO.findOperatorId(operator)); }
//申请日期
if (recelement.attribute("OP_DATE")==null||"".equals(recelement.attribute("OP_DATE").getValue()))
marryAppModel.setApp_date(null);
else{
todate = recelement.attribute("OP_DATE").getValue();
marryAppModel.setApp_date(formatter.parse(todate));
} marryAppModel.setStatus_id("000000003");
if (recelement.attribute("OP_DATE")==null||"".equals(recelement.attribute("OP_DATE").getValue()))
marryAppModel.setStatus_date(null);
else{
todate = recelement.attribute("OP_DATE").getValue();
marryAppModel.setStatus_date(formatter.parse(todate));
} marryAppModel.setOppose_gist(null);
marryAppModel.setOppose_reason(null);
marryAppModel.setCancel_date(null);
if (recelement.attribute("CANCEL_PROOF")==null)
marryAppModel.setCancel_reason("");
else
marryAppModel.setCancel_reason(recelement.attribute("CANCEL_PROOF").getValue());
marryAppModel.setCancel_type_id(null); //if (recelement.attribute("OP_DATE")==null||"".equals(recelement.attribute("OP_DATE").getValue()))
// marryAppModel.setModify_date(null);
//else{
// todate = recelement.attribute("OP_DATE").getValue();
marryAppModel.setModify_date(new Date(System.currentTimeMillis()));
//} marryAppModel.setModify_person(null);
marryAppModel.setMemo(null);
marryAppModel.setArchives_num(null);
// marryAppModel.setReg_person(userName);
// marryAppModel.setReg_person_id(userId);
todate = recelement.attribute("OP_DATE").getValue();
marryAppModel.setDraw_date(formatter.parse(todate)); //根据recelement 拼装 MarryPersonModel MarryPersonModel marryPersonModel = new MarryPersonModel(); //计算年龄,结婚和离婚根据OP_DATE来计算,如果是补证,根据OLD_OP_DATE来计算
int m_age ;
int f_age ;
if(op_type.equals("IA")||op_type.equals("IB")){
if (recelement.attribute("OP_DATE").getValue()!=null){
String op_date = recelement.attribute("OP_DATE").getValue();
if(recelement.attribute("BIRTH_MAN").getValue()!=null){
String birth_man = recelement.attribute("BIRTH_MAN").getValue();
m_age = Integer.valueOf(op_date.substring(0, 4)).intValue() - Integer.valueOf(birth_man.substring(0, 4)).intValue();
marryPersonModel.setM_age(m_age);
}
if(recelement.attribute("BIRTH_WOMAN").getValue()!=null){
String birth_woman = recelement.attribute("BIRTH_WOMAN").getValue();
f_age = Integer.valueOf(op_date.substring(0, 4)).intValue() - Integer.valueOf(birth_woman.substring(0, 4)).intValue();
marryPersonModel.setF_age(f_age);
}
}
}
else if(op_type.equals("ICA")||op_type.equals("ICB")){
if (recelement.attribute("OLD_OP_DATE").getValue()!=null){
String old_op_date = recelement.attribute("OLD_OP_DATE").getValue();
if(recelement.attribute("BIRTH_MAN").getValue()!=null){
String birth_man = recelement.attribute("BIRTH_MAN").getValue();
m_age = Integer.valueOf(old_op_date.substring(0, 4)).intValue() - Integer.valueOf(birth_man.substring(0, 4)).intValue();
marryPersonModel.setM_age(m_age);
}
if(recelement.attribute("BIRTH_WOMAN").getValue()!=null){
String birth_woman = recelement.attribute("BIRTH_WOMAN").getValue();
f_age = Integer.valueOf(old_op_date.substring(0, 4)).intValue() - Integer.valueOf(birth_woman.substring(0, 4)).intValue();
marryPersonModel.setF_age(f_age);
}
}
} if (recelement.attribute("ID_TYPE_MAN")==null)
marryPersonModel.setM_apply_type(null);
else
marryPersonModel.setM_apply_type(getDic("fb2", recelement.attribute("ID_TYPE_MAN").getValue()));
if (recelement.attribute("ID_TYPE_WOMAN")==null)
marryPersonModel.setF_apply_type(null);
else
marryPersonModel.setF_apply_type(getDic("fb2", recelement.attribute("ID_TYPE_WOMAN").getValue()));
if (recelement.attribute("CERT_TYPE_MAN")==null)
marryPersonModel.setM_cert_type(null);
else
marryPersonModel.setM_cert_type(getDic("fb3", recelement.attribute("CERT_TYPE_MAN").getValue()));
if (recelement.attribute("CERT_TYPE_WOMAN")==null)
marryPersonModel.setF_cert_type(null);
else
marryPersonModel.setF_cert_type(getDic("fb3", recelement.attribute("CERT_TYPE_WOMAN").getValue()));
if (recelement.attribute("CERT_NUM_MAN")==null)
marryPersonModel.setM_cert_id(null);
else
marryPersonModel.setM_cert_id(recelement.attribute("CERT_NUM_MAN").getValue());
if (recelement.attribute("CERT_NUM_WOMAN")==null)
marryPersonModel.setF_cert_id(null);
else
marryPersonModel.setF_cert_id(recelement.attribute("CERT_NUM_WOMAN").getValue());
if (recelement.attribute("NAME_MAN")==null)
marryPersonModel.setM_name(null);
else
marryPersonModel.setM_name(recelement.attribute("NAME_MAN").getValue());
if (recelement.attribute("NAME_WOMAN")==null);
else
marryPersonModel.setF_name(recelement.attribute("NAME_WOMAN").getValue());
if (recelement.attribute("BIRTH_MAN")==null)
todate = "";
else{
todate = recelement.attribute("BIRTH_MAN").getValue();
marryPersonModel.setM_born_date(formatter.parse(todate));
}
if (recelement.attribute("BIRTH_WOMAN")==null)
todate = "";
else{
todate = recelement.attribute("BIRTH_WOMAN").getValue();
marryPersonModel.setF_born_date(formatter.parse(todate));
} marryPersonModel.setM_nationality_id(getDic("fb4", recelement.attribute("NATION_MAN").getValue()));
marryPersonModel.setF_natinality_id(getDic("fb4", recelement.attribute("NATION_WOMAN").getValue()));
if (recelement.attribute("FOLK_MAN")==null)
marryPersonModel.setM_nation_id("");
else
marryPersonModel.setM_nation_id(getDic("fb5", recelement.attribute("FOLK_MAN").getValue()));
if (recelement.attribute("FOLK_WOMAN")==null)
marryPersonModel.setF_nation_id(null);
else
marryPersonModel.setF_nation_id(getDic("fb5", recelement.attribute("FOLK_WOMAN").getValue()));
if (recelement.attribute("DEGREE_MAN")==null)
marryPersonModel.setM_education_id("");
else
marryPersonModel.setM_education_id(getDic("fb7", recelement.attribute("DEGREE_MAN").getValue()));
if (recelement.attribute("DEGREE_WOMAN")==null)
marryPersonModel.setF_education_id(null);
else
marryPersonModel.setF_education_id(getDic("fb7", recelement.attribute("DEGREE_WOMAN").getValue()));
if (recelement.attribute("JOB_MAN")==null)
marryPersonModel.setM_vocation(null);
else
marryPersonModel.setM_vocation(getDic("fb6", recelement.attribute("JOB_MAN").getValue()));
if (recelement.attribute("JOB_WOMAN")==null)
marryPersonModel.setF_vocation(null);
else
marryPersonModel.setF_vocation(getDic("fb6", recelement.attribute("JOB_WOMAN").getValue()));
marryPersonModel.setM_address_type(null);
marryPersonModel.setF_address_type(null);
if (recelement.attribute("REG_QX_MAN")==null)
marryPersonModel.setM_address_area(null);
else
marryPersonModel.setM_address_area(getDic("fb9", recelement.attribute("REG_QX_MAN").getValue()));
if (recelement.attribute("REG_QX_WOMAN")==null)
marryPersonModel.setF_address_area(null);
else
marryPersonModel.setF_address_area(getDic("fb9", recelement.attribute("REG_QX_WOMAN").getValue()));
marryPersonModel.setM_neighborhood(null);
marryPersonModel.setF_neighborhood(null);
if(recelement.attribute("REG_DETAIL_MAN")==null)
marryPersonModel.setM_dwelling_place(null);
else
marryPersonModel.setM_dwelling_place(recelement.attribute("REG_DETAIL_MAN").getValue());
if(recelement.attribute("REG_DETAIL_WOMAN")==null)
marryPersonModel.setF_drellin_place(null);
else
marryPersonModel.setF_drellin_place(recelement.attribute("REG_DETAIL_WOMAN").getValue());
if(recelement.attribute("LINK_KIND_MAN")==null)
marryPersonModel.setM_contact_phone(null);
else
marryPersonModel.setM_contact_phone(recelement.attribute("LINK_KIND_MAN").getValue());
if (recelement.attribute("LINK_KIND_WOMAN")==null)
marryPersonModel.setF_contact_phon(null);
else
marryPersonModel.setF_contact_phon(recelement.attribute("LINK_KIND_WOMAN").getValue());
if(recelement.attribute("MARRY_STATUS_MAN")==null)
marryPersonModel.setM_marry_status(null);
else
marryPersonModel.setM_marry_status(getDic("fb8", recelement.attribute("MARRY_STATUS_MAN").getValue()));
if(recelement.attribute("MARRY_STATUS_WOMAN")==null)
marryPersonModel.setF_marry_status(null);
else
marryPersonModel.setF_marry_status(getDic("fb8", recelement.attribute("MARRY_STATUS_WOMAN").getValue()));
marryPersonModel.setM_divorce_reg_date(null);
marryPersonModel.setF_devioce_date(null);
marryPersonModel.setM_divorce_cert_no(null);
marryPersonModel.setF_devioce_cert(null);
if (recelement.attribute("CERT_PROOF_MAN")==null)
marryPersonModel.setM_zjzmclqk(null);
else
marryPersonModel.setM_zjzmclqk(recelement.attribute("CERT_PROOF_MAN").getValue());
if (recelement.attribute("CERT_PROOF_WOMAN")==null)
marryPersonModel.setF_zjzmclqk(null);
else
marryPersonModel.setF_zjzmclqk(recelement.attribute("CERT_PROOF_WOMAN").getValue());
if (recelement.attribute("PRINT_NUM_MAN")==null)
marryPersonModel.setM_paper_no(null);
else
marryPersonModel.setM_paper_no(recelement.attribute("PRINT_NUM_MAN").getValue());
if (recelement.attribute("PRINT_NUM_WOMAN")==null)
marryPersonModel.setF_paper_no(null);
else
marryPersonModel.setF_paper_no(recelement.attribute("PRINT_NUM_WOMAN").getValue());
if (recelement.attribute("REG_DETAIL_MAN")==null)
marryPersonModel.setM_hj_address(null);
else
marryPersonModel.setM_hj_address(recelement.attribute("REG_DETAIL_MAN").getValue());
if (recelement.attribute("REG_DETAIL_MAN")==null)
marryPersonModel.setF_hj_address(null);
else
marryPersonModel.setF_hj_address(recelement.attribute("REG_DETAIL_WOMAN").getValue()); marryPersonModel.setMemo(null); //根据recelement 拼装 MarryProofModel
MarryProofModel marryProofModel = new MarryProofModel(); if (recelement.attribute("REDO_REASON")==null)
marryProofModel.setProof_reason(null);
else
marryProofModel.setProof_reason(getDic("fb11", recelement.attribute("REDO_REASON").getValue()));
if (recelement.attribute("OLD_DEPT_NAME")==null)
marryProofModel.setReg_organ("");
else
marryProofModel.setReg_organ(null); if (recelement.attribute("OLD_CERT_NO")==null)
marryProofModel.setMarry_cert_no("");
else
marryProofModel.setMarry_cert_no(recelement.attribute("OLD_CERT_NO").getValue()); if (recelement.attribute("OLD_OP_DATE")==null|| "".equals(recelement.attribute("OLD_OP_DATE").getValue()))
marryProofModel.setMarry_date(null);
else{
todate = recelement.attribute("OLD_OP_DATE").getValue();
marryProofModel.setMarry_date(formatter.parse(todate));
}
if (recelement.attribute("OLD_OP_DATE")==null|| "".equals(recelement.attribute("OLD_OP_DATE").getValue()))
marryProofModel.setDraw_date(null);
else{
todate = recelement.attribute("OLD_OP_DATE").getValue();
marryProofModel.setDraw_date(formatter.parse(todate));
}
marryProofModel.setProof_no(null);
if (recelement.attribute("DELEGATE_FLAG")==null)
marryProofModel.setIf_proxy(null);
else
marryProofModel.setIf_proxy(recelement.attribute("DELEGATE_FLAG").getValue());
if (recelement.attribute("DELEGATED_NAME")==null)
marryProofModel.setProxy_name(null);
else
marryProofModel.setProxy_name(recelement.attribute("DELEGATED_NAME").getValue());
if (recelement.attribute("DELEGATED_CERT_NO")==null)
marryProofModel.setProxy_cert_id(null);
else
marryProofModel.setProxy_cert_id(recelement.attribute("DELEGATED_CERT_NO").getValue());
marryProofModel.setMemo(null);
if (recelement.attribute("APPLY_MAN")==null)
marryProofModel.setApplicant_gender(null);
else{
String str = recelement.attribute("APPLY_MAN").getValue();
if (str == "01"){
marryProofModel.setApplicant_gender("1");
}
else if(str == "10"){
marryProofModel.setApplicant_gender("2");
}
else{
marryProofModel.setApplicant_gender("3");
}
} /**
*如果certNum证字号存在,对现有记录进行更新
*/
if(isExist(certNum)){
//"IA" 对应系统中的 app_case_type=000000011 涉外结婚申请, flow_id=000000001 结婚登记
if (op_type.equals("IA")){
serialManageModel.setSerial_type("000000005");
serialManageModel.setOrgan_id("000310999");
//得到appNO
marryAppModel.setApp_no(getAppNo(certNum));
marryAppModel.setApp_case_type("000000011");
marryAppModel.setFlow_id("000000001");
marryAppModel.setCert_no(certNum);
//转换证书字号
//证书字号为13位 沪外结2009001288 转换为 2009沪外结000002
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// //证书字号为14位 沪外补结2009001288 2009沪外补结000002
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
//
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合结婚条件,准予登记");
marryPersonModel.setApp_no(marryAppModel.getApp_no());
// 根据recelement 拼装 MarryRegModel
MarryRegModel marryRegModel = new MarryRegModel();
marryRegModel.setApp_no(marryAppModel.getApp_no());
marryRegModel.setCohabit_date(null);
marryRegModel.setIf_reproof(null);
if (recelement.attribute("RENEW_FLAG")==null)
marryRegModel.setIf_resume(null);
else
marryRegModel.setIf_resume(recelement.attribute("RENEW_FLAG").getValue());
marryRegModel.setMemo(null); MarryRegDAO marryRegDAO = new MarryRegDAO(conn);
marryRegDAO.updateMarryReg(marryRegModel);
} //"IB" 对应系统中的 app_case_type=000000012 涉外离婚申请, flow_id=000000002 离婚登记
else if(op_type.equals("IB")){
serialManageModel.setSerial_type("000000006");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryAppModel.setApp_case_type("000000012");
marryAppModel.setFlow_id("000000002"); marryAppModel.setCert_no(certNum);
marryAppModel.setCert_serial_no(certNum);
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
marryAppModel.setApprove_opnn("符合离婚条件,准予登记");
marryPersonModel.setApp_no(marryAppModel.getApp_no()); //根据recelement 拼装 MarryDivorceRegModel
MarryDivorceRegModel marryDivorceRegModel = new MarryDivorceRegModel(); marryDivorceRegModel.setApp_no(marryAppModel.getApp_no());
marryDivorceRegModel.setDivorce_reason(getDic("fb10", recelement.attribute("DIVORCE_REASON").getValue()));
marryDivorceRegModel.setDivorce_type_id(null);
if (recelement.attribute("OLD_CERT_NO")==null)
marryDivorceRegModel.setMarry_cert_no(null);
else
marryDivorceRegModel.setMarry_cert_no(OldcertNum);
if (recelement.attribute("OLD_OP_DATE")==null|| "".equals(recelement.attribute("OLD_OP_DATE").getValue()))
marryDivorceRegModel.setMarry_date(null);
else{
todate = recelement.attribute("OLD_OP_DATE").getValue();
marryDivorceRegModel.setMarry_date(formatter.parse(todate));
}
if (recelement.attribute("OLD_DEPT_NAME")==null)
marryDivorceRegModel.setMarry_organ_id("");
else
marryDivorceRegModel.setMarry_organ_id(recelement.attribute("OLD_DEPT_NAME").getValue());
marryDivorceRegModel.setMemo(null); MarryDivorceRegDAO marryDivorceRegDAO = new MarryDivorceRegDAO(conn);
marryDivorceRegDAO.updateMarryDivorceReg(marryDivorceRegModel);
} //"ICA" 对应系统中的 app_case_type=000000013 涉外结婚补证, flow_id=000000003 结婚补证
else if(op_type.equals("ICA")){
serialManageModel.setSerial_type("000000007");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryPersonModel.setApp_no(marryAppModel.getApp_no());
marryProofModel.setApp_no(marryAppModel.getApp_no());
marryAppModel.setApp_case_type("000000013");
marryAppModel.setFlow_id("000000003");
marryAppModel.setCert_no(certNum);
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合补发条件,准予补发"); MarryProofDAO marryProofDAO = new MarryProofDAO(conn);
marryProofDAO.updateMarryProof(marryProofModel); } //"ICB" 对应系统中的 app_case_type=000000014 涉外离婚补证, flow_id=000000004 离婚补证
else{
serialManageModel.setSerial_type("000000008");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryPersonModel.setApp_no(marryAppModel.getApp_no());
marryProofModel.setApp_no(marryAppModel.getApp_no());
marryAppModel.setApp_case_type("000000014");
marryAppModel.setFlow_id("000000004");
marryAppModel.setCert_no(certNum);
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合补发条件,准予补发"); MarryProofDAO marryProofDAO = new MarryProofDAO(conn);
marryProofDAO.updateMarryProof(marryProofModel);
};
MarryAppDAO marryAppDAO = new MarryAppDAO(conn);
marryAppDAO.updateMarryApp(marryAppModel); MarryPersonDAO marryPersonDAO = new MarryPersonDAO(conn);
marryPersonDAO.updateMarryPerson(marryPersonModel); } /**
*如果certNum证字号不存在,将该记录插入系统中
*/
else{
//涉外结婚登记
if (op_type.equals("IA")){
serialManageModel.setSerial_type("000000005");
serialManageModel.setOrgan_id("000310999"); //生成最新的app_no
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel)); marryAppModel.setApp_case_type("000000011");
marryAppModel.setFlow_id("000000001");
marryAppModel.setCert_no(certNum);
//证书字号转换
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合补发条件,准予补发");
marryPersonModel.setApp_no(marryAppModel.getApp_no());
// 根据recelement 拼装 MarryRegModel
MarryRegModel marryRegModel = new MarryRegModel();
marryRegModel.setApp_no(marryAppModel.getApp_no());
marryRegModel.setCohabit_date(null);
marryRegModel.setIf_reproof(null);
if (recelement.attribute("RENEW_FLAG")==null)
marryRegModel.setIf_resume(null);
else
marryRegModel.setIf_resume(recelement.attribute("RENEW_FLAG").getValue());
marryRegModel.setMemo(null); MarryRegDAO marryRegDAO = new MarryRegDAO(conn);
marryRegDAO.insertMarryReg(marryRegModel);
} //涉外离婚登记
else if(op_type.equals("IB")){ serialManageModel.setSerial_type("000000006");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryAppModel.setApp_case_type("000000012");
marryAppModel.setFlow_id("000000002");
marryAppModel.setCert_no(certNum);
//证书字号转换
// if (certNum.length()==13)
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合离婚条件,准予登记");
marryPersonModel.setApp_no(marryAppModel.getApp_no());
//根据recelement 拼装 MarryDivorceRegModel
MarryDivorceRegModel marryDivorceRegModel = new MarryDivorceRegModel(); marryDivorceRegModel.setApp_no(marryAppModel.getApp_no());
marryDivorceRegModel.setDivorce_reason(getDic("fb10", recelement.attribute("DIVORCE_REASON").getValue()));
marryDivorceRegModel.setDivorce_type_id(null);
if (recelement.attribute("OLD_CERT_NO")==null)
marryDivorceRegModel.setMarry_cert_no(null);
else
marryDivorceRegModel.setMarry_cert_no(OldcertNum);
if (recelement.attribute("OLD_OP_DATE")==null|| "".equals(recelement.attribute("OLD_OP_DATE").getValue()))
marryDivorceRegModel.setMarry_date(null);
else{
todate = recelement.attribute("OLD_OP_DATE").getValue();
marryDivorceRegModel.setMarry_date(formatter.parse(todate));
}
if (recelement.attribute("OLD_DEPT_NAME")==null)
marryDivorceRegModel.setMarry_organ_id("");
else
marryDivorceRegModel.setMarry_organ_id(recelement.attribute("OLD_DEPT_NAME").getValue());
marryDivorceRegModel.setMemo(null); MarryDivorceRegDAO marryDivorceRegDAO = new MarryDivorceRegDAO(conn);
marryDivorceRegDAO.insertMarryDivorceReg(marryDivorceRegModel);
} //涉外结婚补证
else if(op_type.equals("ICA")){
// marry_person,marry_proof,marry_app 结婚补证
serialManageModel.setSerial_type("000000007");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryPersonModel.setApp_no(marryAppModel.getApp_no());
marryProofModel.setApp_no(marryAppModel.getApp_no());
marryAppModel.setApp_case_type("000000013");
marryAppModel.setFlow_id("000000003");
marryAppModel.setCert_no(certNum);
// if (certNum.length()==13)
// //沪外结2009001288 2009沪外结000002
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// //沪外补结2009001288 2009沪外补结000002
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合补发条件,准予补发"); MarryProofDAO marryProofDAO = new MarryProofDAO(conn);
marryProofDAO.insertMarryProof(marryProofModel);
} //涉外离婚补证
else{
// marry_person,marry_proof,marry_app 离婚补证
serialManageModel.setSerial_type("000000008");
serialManageModel.setOrgan_id("000310999");
serialManageModel = (SerialManageModel)dao.getSerialManage(serialManageModel);
dao.updateSerialManageSelfAdd(serialManageModel);
marryAppModel.setApp_no(SerialManageUtil.getOutRegistAppNo("000310999", serialManageModel));
marryPersonModel.setApp_no(marryAppModel.getApp_no());
marryProofModel.setApp_no(marryAppModel.getApp_no());
marryAppModel.setApp_case_type("000000014");//000000011 涉外结婚申请000000012 涉外离婚申请000000013 涉外结婚办证申请000000014 涉外离婚办证申请
marryAppModel.setFlow_id("000000004");//000000001 结婚登记 000000002 离婚登记 000000003 结婚补证 000000004 离婚补证 000000005 撤销结婚登记
marryAppModel.setCert_no(certNum);
// if (certNum.length()==13)
// //沪外结2009001288 2009沪外结000002
// marryAppModel.setCert_serial_no(certNum.substring(4,7)+certNum.substring(0, 4)+certNum.substring(7, 13));
// else
// //沪外补结2009001288 2009沪外补结000002
// marryAppModel.setCert_serial_no(certNum.substring(4,8)+certNum.substring(0, 4)+certNum.substring(8, 14));
//
marryAppModel.setCert_serial_no(certNum);
marryAppModel.setApprove_opnn("符合补发条件,准予补发"); MarryProofDAO marryProofDAO = new MarryProofDAO(conn);
marryProofDAO.insertMarryProof(marryProofModel);
};
MarryAppDAO marryAppDAO = new MarryAppDAO(conn);
marryAppDAO.insertMarryApp(marryAppModel); MarryPersonDAO marryPersonDAO = new MarryPersonDAO(conn);
marryPersonDAO.insertMarryPerson(marryPersonModel); } /**
* 主要信息更新或者插入完成后,对MarryPrsnStatus表进行更新或者插入。
* 表中会分别以男方和女方信息为主生成两条记录
*/
//拼装MarryPrsnStatusModel
MarryPrsnStatusModel marryPrsnStatusModel= new MarryPrsnStatusModel();
MarryPrsnStatusDAO marryPrsnStatusDAO = new MarryPrsnStatusDAO(conn); //以男方信息为主更新或插入
//男女双方对应信息已存在,对已存在信息进行更新
if (ifPrsnExists(recelement.attribute("NAME_MAN").getValue(), recelement.attribute("CERT_NUM_MAN").getValue())){
if (recelement.attribute("CERT_TYPE_MAN")==null)
marryPrsnStatusModel.setCert_type("");
else
marryPrsnStatusModel.setCert_type(getDic("fb3", recelement.attribute("CERT_TYPE_MAN").getValue())); if (recelement.attribute("CERT_NUM_MAN")==null)
marryPrsnStatusModel.setCert_no("");
else
marryPrsnStatusModel.setCert_no(recelement.attribute("CERT_NUM_MAN").getValue());
if (recelement.attribute("NAME_MAN")==null)
marryPrsnStatusModel.setName("");
else
marryPrsnStatusModel.setName(recelement.attribute("NAME_MAN").getValue());
marryPrsnStatusModel.setSex_id("1");//直接为男性
//结婚
if (op_type.equals("IA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚
else if(op_type.equals("IB")){
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
//结婚补证
else if(op_type.equals("ICA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚补证
else{
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
if (recelement.attribute("NAME_WOMAN")==null)
marryPrsnStatusModel.setMate_name("");
else
marryPrsnStatusModel.setMate_name(recelement.attribute("NAME_WOMAN").getValue());
if (recelement.attribute("CERT_TYPE_WOMAN")==null)
marryPrsnStatusModel.setMate_cert_id("");
else
marryPrsnStatusModel.setMate_cert_id(getDic("fb3", recelement.attribute("CERT_TYPE_WOMAN").getValue()));
if (recelement.attribute("CERT_NUM_WOMAN")==null)
marryPrsnStatusModel.setMate_cert_no("");
else
marryPrsnStatusModel.setMate_cert_no(recelement.attribute("CERT_NUM_WOMAN").getValue()); marryPrsnStatusModel.setCertificate_no(marryAppModel.getCert_no());
marryPrsnStatusModel.setReg_date(marryAppModel.getDraw_date());
if (recelement.attribute("DEPT_NAME")==null)
marryPrsnStatusModel.setOrgan_name("");
else
marryPrsnStatusModel.setOrgan_name(recelement.attribute("DEPT_NAME").getValue());
marryPrsnStatusModel.setLast_update_date(null);
marryPrsnStatusModel.setApp_no(marryAppModel.getApp_no());
marryPrsnStatusModel.setMemo(null);
marryPrsnStatusDAO.updateMarryPrsnStatus(marryPrsnStatusModel);
} //信息不存在,进行插入操作 else{
//insert
if (recelement.attribute("CERT_TYPE_MAN")==null)
marryPrsnStatusModel.setCert_type("");
else
marryPrsnStatusModel.setCert_type(getDic("fb3", recelement.attribute("CERT_TYPE_MAN").getValue())); if (recelement.attribute("CERT_NUM_MAN")==null)
marryPrsnStatusModel.setCert_no("");
else
marryPrsnStatusModel.setCert_no(recelement.attribute("CERT_NUM_MAN").getValue());
if (recelement.attribute("NAME_MAN")==null)
marryPrsnStatusModel.setName("");
else
marryPrsnStatusModel.setName(recelement.attribute("NAME_MAN").getValue());
marryPrsnStatusModel.setSex_id("1");//直接为男性
//结婚
if (op_type.equals("IA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚
else if(op_type.equals("IB")){
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
//结婚补证
else if(op_type.equals("ICA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚补证
else{
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
if (recelement.attribute("NAME_WOMAN")==null)
marryPrsnStatusModel.setMate_name("");
else
marryPrsnStatusModel.setMate_name(recelement.attribute("NAME_WOMAN").getValue());
if (recelement.attribute("CERT_TYPE_WOMAN")==null)
marryPrsnStatusModel.setMate_cert_id("");
else
marryPrsnStatusModel.setMate_cert_id(getDic("fb3", recelement.attribute("CERT_TYPE_WOMAN").getValue()));
if (recelement.attribute("CERT_NUM_WOMAN")==null)
marryPrsnStatusModel.setMate_cert_no("");
else
marryPrsnStatusModel.setMate_cert_no(recelement.attribute("CERT_NUM_WOMAN").getValue()); marryPrsnStatusModel.setCertificate_no(marryAppModel.getCert_no());
marryPrsnStatusModel.setReg_date(marryAppModel.getDraw_date());
if (recelement.attribute("DEPT_NAME")==null)
marryPrsnStatusModel.setOrgan_name("");
else
marryPrsnStatusModel.setOrgan_name(recelement.attribute("DEPT_NAME").getValue());
marryPrsnStatusModel.setLast_update_date(null);
marryPrsnStatusModel.setApp_no(marryAppModel.getApp_no());
marryPrsnStatusModel.setMemo(null); marryPrsnStatusDAO.insertMarryPrsnStatus(marryPrsnStatusModel);
}; //男女双方对应信息已存在,对已存在信息进行更新
//以女方信息为主更新或插入
if (ifPrsnExists(recelement.attribute("NAME_WOMAN").getValue(), recelement.attribute("CERT_NUM_WOMAN").getValue())){
//update
if (recelement.attribute("CERT_TYPE_WOMAN")==null)
marryPrsnStatusModel.setCert_type("");
else
marryPrsnStatusModel.setCert_type(getDic("fb3", recelement.attribute("CERT_TYPE_WOMAN").getValue())); if (recelement.attribute("CERT_NUM_WOMAN")==null)
marryPrsnStatusModel.setCert_no("");
else
marryPrsnStatusModel.setCert_no(recelement.attribute("CERT_NUM_WOMAN").getValue());
if (recelement.attribute("NAME_WOMAN")==null)
marryPrsnStatusModel.setName("");
else
marryPrsnStatusModel.setName(recelement.attribute("NAME_WOMAN").getValue());
marryPrsnStatusModel.setSex_id("2");//直接为女性
//结婚
if (op_type.equals("IA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚
else if(op_type.equals("IB")){
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
//结婚补证
else if(op_type.equals("ICA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚补证
else{
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
if (recelement.attribute("NAME_MAN")==null)
marryPrsnStatusModel.setMate_name("");
else
marryPrsnStatusModel.setMate_name(recelement.attribute("NAME_MAN").getValue());
if (recelement.attribute("CERT_TYPE_MAN")==null)
marryPrsnStatusModel.setMate_cert_id("");
else
marryPrsnStatusModel.setMate_cert_id(getDic("fb3", recelement.attribute("CERT_TYPE_MAN").getValue()));
if (recelement.attribute("CERT_NUM_MAN")==null)
marryPrsnStatusModel.setMate_cert_no("");
else
marryPrsnStatusModel.setMate_cert_no(recelement.attribute("CERT_NUM_MAN").getValue()); marryPrsnStatusModel.setCertificate_no(marryAppModel.getCert_no());
marryPrsnStatusModel.setReg_date(marryAppModel.getDraw_date());
if (recelement.attribute("DEPT_NAME")==null)
marryPrsnStatusModel.setOrgan_name("");
else
marryPrsnStatusModel.setOrgan_name(recelement.attribute("DEPT_NAME").getValue());
marryPrsnStatusModel.setLast_update_date(null);
marryPrsnStatusModel.setApp_no(marryAppModel.getApp_no());
marryPrsnStatusModel.setMemo(null);
marryPrsnStatusDAO.updateMarryPrsnStatus(marryPrsnStatusModel);
}
else{
//insert
//以女方信息为主插入
if (recelement.attribute("CERT_TYPE_WOMAN")==null)
marryPrsnStatusModel.setCert_type("");
else
marryPrsnStatusModel.setCert_type(getDic("fb3", recelement.attribute("CERT_TYPE_WOMAN").getValue())); if (recelement.attribute("CERT_NUM_WOMAN")==null)
marryPrsnStatusModel.setCert_no("");
else
marryPrsnStatusModel.setCert_no(recelement.attribute("CERT_NUM_WOMAN").getValue());
if (recelement.attribute("NAME_WOMAN")==null)
marryPrsnStatusModel.setName("");
else
marryPrsnStatusModel.setName(recelement.attribute("NAME_WOMAN").getValue());
marryPrsnStatusModel.setSex_id("2");//直接为女性
//结婚
if (op_type.equals("IA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚
else if(op_type.equals("IB")){
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
//结婚补证
else if(op_type.equals("ICA")){
marryPrsnStatusModel.setMarry_status_name("已婚");
marryPrsnStatusModel.setMarry_status("000000002");
}
//离婚补证
else{
marryPrsnStatusModel.setMarry_status_name("离婚");
marryPrsnStatusModel.setMarry_status("000000004");
}
if (recelement.attribute("NAME_MAN")==null)
marryPrsnStatusModel.setMate_name("");
else
marryPrsnStatusModel.setMate_name(recelement.attribute("NAME_MAN").getValue());
if (recelement.attribute("CERT_TYPE_MAN")==null)
marryPrsnStatusModel.setMate_cert_id("");
else
marryPrsnStatusModel.setMate_cert_id(getDic("fb3", recelement.attribute("CERT_TYPE_MAN").getValue()));
if (recelement.attribute("CERT_NUM_MAN")==null)
marryPrsnStatusModel.setMate_cert_no("");
else
marryPrsnStatusModel.setMate_cert_no(recelement.attribute("CERT_NUM_MAN").getValue()); marryPrsnStatusModel.setCertificate_no(marryAppModel.getCert_no());
marryPrsnStatusModel.setReg_date(marryAppModel.getDraw_date());
if (recelement.attribute("DEPT_NAME")==null)
marryPrsnStatusModel.setOrgan_name("");
else
marryPrsnStatusModel.setOrgan_name(recelement.attribute("DEPT_NAME").getValue());
marryPrsnStatusModel.setLast_update_date(null);
marryPrsnStatusModel.setApp_no(marryAppModel.getApp_no());
marryPrsnStatusModel.setMemo(null);
marryPrsnStatusDAO.insertMarryPrsnStatus(marryPrsnStatusModel);
} }
}
try {
commit(conn);
}
catch (SQLException sqle) {
rollback(conn);
Debug.debug(this.getClass(),"updateDivorceRegist sqle="+sqle.toString());
throw DB_ERROR;
} }
catch (LogicException le) {
rollback(conn);
throw le;
} catch(DocumentException e)
{
//System.out.println(e.getMessage());
return false;
}
finally {
releaseConnection(conn);
}
return true;
} /**
* 判断 marry_prsn_status 表中该人员是否存在
* @param name 申请人姓名
* @param certNo 申请人证件号码
* @return ifExists
*/
private boolean ifPrsnExists(String name, String certNo){
Connection conn= null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
boolean ifExists = false;
try{
sql = "select * from marry_prsn_status where name = ? and cert_no = ?";
conn=getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setString(2,certNo); rs = pstmt.executeQuery();
if (rs.next())
ifExists = true;
else
ifExists = false; }catch(Exception e){
e.printStackTrace();
}
finally {
releaseConnection(conn,pstmt,rs);
}
return ifExists; }
/**
* 字典转换
* @param dic_name 字典编号
* @param dic_col 名称序号
* @return dic_xt 转换后的数据
*/
private String getDic(String dic_name, String dic_col){
Connection conn= null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String dic_xt = "";
try{
sql = "select id from dic_hy_outrelation where dic_id = ? and out_item_id = ?";
conn=getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,dic_name);
pstmt.setString(2,dic_col);
rs = pstmt.executeQuery();
while(rs.next()){
dic_xt=rs.getString(1);
} }catch(Exception e){
e.printStackTrace();
}
finally {
releaseConnection(conn,pstmt,rs);
}
return dic_xt; } /**
* 证书字号转换
* @param cert_id
* @return
*/
private String getCertId(String cert_id){
String cert = ""; String str [] = cert_id.split("-");
if(str[0].length()<9){
//区县
cert = getNameBy6(cert_id);
}else{
//乡镇
cert = getNameBy9(cert_id);
}
return cert; } /*
* 证书字号转换
*/
private String getNameBy6(String name){
String temp ="";
String str = "";
String num = "";
String end = "";
String t1 = name.substring(0,1);
if(t1.equals("J")){
temp = "沪外结";
str = name.substring(8,12);
num = name.substring(13,18);
}else if(t1.equals("L")){
temp = "沪外离";
str = name.substring(8,12);
num = name.substring(13,18);
}else{
String t2 = name.substring(0,2);
if(t2.equals("BJ")){
temp = "沪外补结";
str = name.substring(9,13);
num = name.substring(14,19);
}
else{
temp = "沪外补离";
str = name.substring(9,13);
num = name.substring(14,19);
}
}
end =str+temp+"0"+num;
return end; } /*
* 证书字号转换
*/
private String getNameBy9(String name){
String temp ="";
String str = "";
String num = "";
String end = "";
String t1 = name.substring(0,1);
if(t1.equals("J")){
temp = "沪外结";
str = name.substring(11,15);
num = name.substring(16,21);
}else if(t1.equals("L")){
temp = "沪外离";
str = name.substring(11,15);
num = name.substring(16,21);
}else{
String t2 = name.substring(0,2);
if(t2.equals("BJ")){
temp = "沪外补结";
str = name.substring(12,16);
num = name.substring(17,22);
}
else{
temp = "沪外补离";
str = name.substring(12,16);
num = name.substring(17,22);
}
}
end =str+temp+"0"+num;
return end; } /**
* 判断XML文件中的数据在数据库中是否存在
* @param cert_name XML中的证书字号
* @return temp 存在为true
*/
private boolean isExist(String cert_name){
Connection conn= null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
boolean temp = false;
try{
sql = "select * from marry_app where cert_no = ?";
conn=getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,cert_name);
rs = pstmt.executeQuery();
while(rs.next()){
temp = true;
} }catch(Exception e){
e.printStackTrace(); }
finally {
releaseConnection(conn,pstmt,rs);
}
return temp; } /**
* 判断XML文件中的数据已经存在时,得到对应的app_no
* @param cert_name XML中的证书字号
* @return temp 得到app_no
*/
private String getAppNo(String cert_name){
Connection conn= null;
Statement pstmt = null;
ResultSet rs = null;
String sql = "";
String temp = "";
try{
sql = "select app_no from marry_app where cert_no = '"+cert_name+"'";
conn=getConnection();
pstmt = conn.prepareStatement(sql);
// pstmt.setString(1,cert_name);
rs = pstmt.executeQuery(sql);
while(rs.next()){
temp = rs.getString(1);
} }catch(Exception e){
e.printStackTrace(); }
finally {
releaseConnection(conn,pstmt,rs);
}
return temp; } }
05-07 15:15