1 2 22 23 package org.webdocwf.util.loader; 24 25 import java.util.*; 26 import java.sql.*; 27 28 34 public class QueryUpdateSet { 35 36 private String strQueryUpdate=null; 37 private Vector indexDummyOverwrite=new Vector(); 38 private Vector indexDummySetNull=new Vector(); 40 private String versionName="version"; 41 42 50 public QueryUpdateSet(Vector vecColumnNames, Vector vecColumnTypes, Vector vecColumnMode, 51 String tableName, boolean oid, String versionName, ConfigReader configReaderTarget) throws LoaderException { 52 53 this.versionName=versionName; 54 strQueryUpdate="update " + tableName + " set "; 56 int counter=0; 57 for (int j = 0; j < vecColumnNames.size(); j++) { 58 counter=j; 59 if (vecColumnMode.get(j).toString().equalsIgnoreCase("Overwrite")) { 60 indexDummyOverwrite.add(String.valueOf(counter)); 61 strQueryUpdate+=vecColumnNames.get(j).toString()+"="; 62 try { 64 String columnType = Utils.replaceAll(vecColumnTypes.get(j).toString()," ","_"); 66 if(!configReaderTarget.isNumber(columnType)){ 67 if(configReaderTarget.isWithN(columnType)){ 68 strQueryUpdate+="N"; 69 } 70 strQueryUpdate+="'dummyOverwrite'"+", "; 71 }else{ 72 strQueryUpdate+="dummyOverwrite"+", "; 73 } 74 } catch (LoaderException e) { 75 LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable )e); 76 throw le; 77 } 78 }else if (vecColumnMode.get(j).toString().equalsIgnoreCase("SetNull")) { 79 strQueryUpdate +="dummySetNull"+", "; 80 indexDummySetNull.add(String.valueOf(counter)); 81 } 82 } 83 if(oid) 84 strQueryUpdate += " "+this.versionName+" = " + "dummyVersionOverwrite" + " where "; 85 else{ 86 int start=strQueryUpdate.lastIndexOf(","); 87 if(start<strQueryUpdate.length()-1&&start!=-1) 88 strQueryUpdate=strQueryUpdate.substring(0,strQueryUpdate.lastIndexOf(",")); 89 strQueryUpdate += " where "; 90 } 91 } 92 93 97 public String getQueryUpdate(){ 98 return this.strQueryUpdate ; 99 } 100 101 105 public Vector getIndexDummyOverwrite(){ 106 return indexDummyOverwrite; 107 } 108 109 113 public Vector getIndexDummySetNull(){ 114 return indexDummySetNull; 115 } 116 117 118 } | Popular Tags |