1 22 23 package org.webdocwf.util.loader; 24 25 import java.util.*; 26 import java.math.*; 27 import java.sql.*; 28 29 36 public class QueryInsertRowCt { 37 private String tableName=""; 38 private Vector columnNamesPstmt=new Vector(); 39 private BigDecimal bdecOidNumber; 40 private boolean bOidLogicCurrentTable=false; 41 private boolean isTOS=false; 42 private String oidColumnName="oid"; 43 private String versionColumnName="version"; 44 private String oidType="decimal"; 45 private String versionType="bigint"; 46 private Hashtable sqlToJavaMap=new Hashtable(); 47 48 58 public QueryInsertRowCt( boolean bOidLogicCurrentTable, boolean isTOS, Vector vecNewColumnNames, 59 Vector vecNewColumnTypes,String tableName, 60 BigDecimal bdecOidNumber,String oidColumnName, 61 String versionColumnName, String oidType, 62 String versionType,Hashtable sqlToJavaMap) { 63 64 this.tableName=tableName; 65 this.oidColumnName=oidColumnName; 66 this.versionColumnName=versionColumnName; 67 this.oidType=oidType; 68 this.versionType=versionType; 69 this.sqlToJavaMap=sqlToJavaMap; 70 this.bOidLogicCurrentTable=bOidLogicCurrentTable; 71 this.bdecOidNumber=bdecOidNumber; 72 this.isTOS=isTOS; 73 if(bOidLogicCurrentTable){ 74 if(isTOS){ 75 columnNamesPstmt.add(this.oidColumnName); 76 }else{ 77 columnNamesPstmt.add(this.oidColumnName); 78 columnNamesPstmt.add(this.versionColumnName); 79 } 80 } 81 82 for (int i = 0; i < vecNewColumnNames.size(); i++) { 83 columnNamesPstmt.add(vecNewColumnNames.get(i).toString()); 84 } 85 86 } 87 88 92 public String getPreperedStatementForInsert(){ 93 String pstmt="insert into "+tableName+" ("; 94 int count=columnNamesPstmt.size(); 95 for (int i = 0; i < count; i++) { 96 if(i!=count-1) 97 pstmt+=columnNamesPstmt.get(i).toString()+","; 98 else 99 pstmt+=columnNamesPstmt.get(i).toString()+")"; 100 } 101 pstmt+=" VALUES ("; 102 for (int i = 0; i < count; i++) { 103 if(i!=count-1){ 104 pstmt+="?,"; 105 }else{ 106 pstmt += "?)"; 107 } 108 } 109 if(bOidLogicCurrentTable){ 110 if (isTOS) { 111 int oid= pstmt.indexOf("?"); 112 pstmt=pstmt.substring(0,oid)+"'"+bdecOidNumber+"'"+pstmt.substring(oid+1); 113 } 114 else { 115 int oid= pstmt.indexOf("?"); 116 pstmt=pstmt.substring(0,oid)+bdecOidNumber.toString()+pstmt.substring(oid+1); 117 int version=pstmt.indexOf("?"); 118 pstmt=pstmt.substring(0,version)+String.valueOf(0)+pstmt.substring(version+1); 119 } 120 } 121 122 return pstmt; 123 } 124 125 } 126 | Popular Tags |