1 2 22 23 package org.webdocwf.util.loader.generator; 24 25 import java.util.Hashtable ; 26 27 import org.webdocwf.util.loader.LoaderException; 28 import org.webdocwf.util.loader.logging.Logger; 29 import org.webdocwf.util.loader.logging.StandardLogger; 30 31 36 public class JdbcParameters { 37 38 private Hashtable parameters; 40 private String dbVendorName="default"; 41 private String driverName="default"; 42 43 private String strDriverClassName=null; 44 private String strConnection=null; 45 private String strUser="default"; 46 private String strPassword="default"; 47 private String strDbVendorsPath=null; 49 private String fileName; 50 private Logger logger; 51 59 public JdbcParameters(String destination, InputParameters generatorParameters) 60 throws LoaderException { 61 setLogger(); 62 this.logger.write("full", "JdbcParameters is started."); 63 parameters = new Hashtable (); 64 65 try { 66 if(destination.equalsIgnoreCase("source")) { 67 this.dbVendorName=generatorParameters.getSourceType(); 68 this.driverName=generatorParameters.getSourceDriverName(); 69 70 SearchXmlFile searchXmlFile=new SearchXmlFile("absolute", 71 generatorParameters.getPathToSourceConf(), 72 generatorParameters.getConfJarStructure()); 73 74 generatorParameters.setExcludedTables(searchXmlFile.getExcludedTables()); 75 76 if(driverName.equalsIgnoreCase("")){ 77 setDriverName(searchXmlFile.getDriverName()); 78 } 79 searchXmlFile.getClassName(getDriverName(),this,generatorParameters); 80 setJdbcParameters("JdbcDriver",strDriverClassName); 81 setJdbcParameters("Connection.Url", strConnection+generatorParameters.getSourceDataBase()); 82 setJdbcParameters("User", generatorParameters.getSourceUser()); 83 setJdbcParameters("Password", generatorParameters.getSourcePassword()); 84 } 85 else if(destination.equalsIgnoreCase("target")) { 86 87 this.dbVendorName=generatorParameters.getTargetType(); 88 this.driverName=generatorParameters.getTargetDriverName(); 89 90 SearchXmlFile searchXmlFile=new SearchXmlFile("absolute", 91 generatorParameters.getPathToTargetConf(), 92 generatorParameters.getConfJarStructure()); 93 if(driverName.equalsIgnoreCase("")){ 94 setDriverName(searchXmlFile.getDriverName()); 95 } 96 searchXmlFile.getClassName(getDriverName(),this,generatorParameters); 97 setJdbcParameters("JdbcDriver", strDriverClassName); 98 setJdbcParameters("Connection.Url", strConnection+generatorParameters.getTargetDataBase()); 99 setJdbcParameters("User", generatorParameters.getTargetUser()); 100 setJdbcParameters("Password", generatorParameters.getTargetPassword()); 101 } 102 } catch (LoaderException e) { 103 LoaderException le = new LoaderException("Exception in class JdbcParameters.Error while set jdbc parameters.",e); 104 this.logger.write("full", "Exception in class JdbcParameters.Error while set jdbc parameters."+le.getStackTraceAsString()); 105 throw le; 106 } 107 this.logger.write("full", "JdbcParameters is finished."); 108 } 109 110 111 116 public void setJdbcParameters(String key, String value){ 117 this.parameters.put(key,value); 118 } 119 120 125 public String getJdbcParameters(String key){ 126 return (String )this.parameters.get(key); 127 } 128 129 133 public Hashtable getAllParameters() { 134 return this.parameters; 135 } 136 137 141 public void setDbVendor(String db_VendorName){ 142 dbVendorName=db_VendorName; 143 } 144 145 149 public String getDbVendor(){ 150 return dbVendorName; 151 } 152 153 157 public void setDriverName(String driver_Name){ 158 driverName=driver_Name; 159 } 160 161 165 public String getDriverName(){ 166 return driverName; 167 } 168 169 170 174 public void setDriverClassName(String driver_ClassName){ 175 strDriverClassName=driver_ClassName; 176 } 177 178 182 public void setConnection(String _connection){ 183 strConnection=_connection; 184 } 185 189 private void setLogger() { 190 this.logger = StandardLogger.getCentralLogger(); 191 } 192 } | Popular Tags |