View Javadoc
1 2 /* 3 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus. 4 5 6 Copyright (C) 2003 Together 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 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 /*** 32 * JdbcParameters class sets the value of jdbc drivers, which can be used in Octopus. 33 * @author Radoslav Dutina 34 * @version 1.0 35 */ 36 public class JdbcParameters { 37 38 //Creating an atribute for source tag 39 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 strAlterTablePrimaryKey="true"; 48 private String strDbVendorsPath=null; 49 private String fileName; 50 private Logger logger; 51 /*** 52 * 53 * @param destination defines the type of the path. If destonation=absolute path is absolute, 54 * if destination=relative path is relative, and if destination=jar, application read from jar 55 * file. 56 * @param generatorParameters represents the references to InputParameter object. 57 * @throws LoaderException 58 */ 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 /*** 112 * This method sets the par (value, key) of jdbc parameters. 113 * @param key is the first jdbc parameter. 114 * @param value is the second jdbc parameter. 115 */ 116 public void setJdbcParameters(String key, String value){ 117 this.parameters.put(key,value); 118 } 119 120 /*** 121 * This method read the value od jdbc parameters 122 * @param key is the first jdbc parameter. 123 * @return is the second jdbc parameter. 124 */ 125 public String getJdbcParameters(String key){ 126 return (String)this.parameters.get(key); 127 } 128 129 /*** 130 * This method read the all jdbc parameters. 131 * @return value of all jdbc parameters. 132 */ 133 public Hashtable getAllParameters() { 134 return this.parameters; 135 } 136 137 /*** 138 * This method sets the value of dbVendor parameter. 139 * @param db_VendorName is value of parameter. 140 */ 141 public void setDbVendor(String db_VendorName){ 142 dbVendorName=db_VendorName; 143 } 144 145 /*** 146 * This method read the value of dbVendor parameter. 147 * @return value of parameter. 148 */ 149 public String getDbVendor(){ 150 return dbVendorName; 151 } 152 153 /*** 154 * This method sets the value of driverName parameter. 155 * @param driver_Name is value of parameter. 156 */ 157 public void setDriverName(String driver_Name){ 158 driverName=driver_Name; 159 } 160 161 /*** 162 * This method read the value of driverName parameter. 163 * @return value od parameter. 164 */ 165 public String getDriverName(){ 166 return driverName; 167 } 168 169 170 /*** 171 * This method sets the value of strDriverClassName parameter. 172 * @param driver_ClassName is value of the parameter. 173 */ 174 public void setDriverClassName(String driver_ClassName){ 175 strDriverClassName=driver_ClassName; 176 } 177 178 /*** 179 * This method sets the value of strConnection parameter. 180 * @param _connection is the value of the parameter. 181 */ 182 public void setConnection(String _connection){ 183 strConnection=_connection; 184 } 185 /*** 186 * This method will set logger object 187 * @param logger 188 */ 189 private void setLogger() { 190 this.logger = StandardLogger.getCentralLogger(); 191 } 192 }

This page was automatically generated by Maven