⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcparameters.java

📁 数据仓库工具
💻 JAVA
字号:

/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.


    Copyright (C) 2003  Together

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package org.webdocwf.util.loader.generator;

import java.util.Hashtable;

import org.webdocwf.util.loader.LoaderException;
import org.webdocwf.util.loader.logging.Logger;
import org.webdocwf.util.loader.logging.StandardLogger;

/**
 * JdbcParameters class sets the value of jdbc drivers, which can be used in Octopus.
 * @author Radoslav Dutina
 * @version 1.0
 */
public class JdbcParameters {

  //Creating an atribute for source tag
  private Hashtable parameters;
  private String dbVendorName="default";
  private String driverName="default";

  private String strDriverClassName=null;
  private String strConnection=null;
  private String strUser="default";
  private String strPassword="default";
//  private String strAlterTablePrimaryKey="true";
  private String strDbVendorsPath=null;
  private String fileName;
  private Logger logger;
  /**
   *
   * @param destination defines the type of the path. If destonation=absolute path is absolute,
   * if destination=relative path is relative, and if destination=jar, application read from jar
   * file.
   * @param generatorParameters represents the references to InputParameter object.
   * @throws LoaderException
   */
  public JdbcParameters(String destination, InputParameters generatorParameters)
      throws LoaderException {
		setLogger();
		this.logger.write("full", "JdbcParameters is started.");
    parameters = new Hashtable();
		
    try {
        if(destination.equalsIgnoreCase("source")) {
          this.dbVendorName=generatorParameters.getSourceType();
          this.driverName=generatorParameters.getSourceDriverName();
        
          SearchXmlFile searchXmlFile=new SearchXmlFile("absolute",
              generatorParameters.getPathToSourceConf(),
              generatorParameters.getConfJarStructure());
        
          generatorParameters.setExcludedTables(searchXmlFile.getExcludedTables());
        
          if(driverName.equalsIgnoreCase("")){
            setDriverName(searchXmlFile.getDriverName());
          }
          searchXmlFile.getClassName(getDriverName(),this,generatorParameters);
          setJdbcParameters("JdbcDriver",strDriverClassName);
          setJdbcParameters("Connection.Url", strConnection+generatorParameters.getSourceDataBase());
          setJdbcParameters("User", generatorParameters.getSourceUser());
          setJdbcParameters("Password", generatorParameters.getSourcePassword());
        }
        else if(destination.equalsIgnoreCase("target")) {
        
          this.dbVendorName=generatorParameters.getTargetType();
          this.driverName=generatorParameters.getTargetDriverName();
        
          SearchXmlFile searchXmlFile=new SearchXmlFile("absolute",
              generatorParameters.getPathToTargetConf(),
              generatorParameters.getConfJarStructure());
          if(driverName.equalsIgnoreCase("")){
            setDriverName(searchXmlFile.getDriverName());
          }
          searchXmlFile.getClassName(getDriverName(),this,generatorParameters);
          setJdbcParameters("JdbcDriver", strDriverClassName);
          setJdbcParameters("Connection.Url", strConnection+generatorParameters.getTargetDataBase());
          setJdbcParameters("User", generatorParameters.getTargetUser());
          setJdbcParameters("Password", generatorParameters.getTargetPassword());
        }
    } catch (LoaderException e) {
			LoaderException le = new LoaderException("Exception in class JdbcParameters.Error while set jdbc parameters.",e);
			this.logger.write("full", "Exception in class JdbcParameters.Error while set jdbc parameters."+le.getStackTraceAsString());
			throw le;
    }
	this.logger.write("full", "JdbcParameters is finished.");
  }


  /**
   * This method sets the par (value, key) of jdbc parameters.
   * @param key is the first jdbc parameter.
   * @param value is the second jdbc parameter.
   */
  public void setJdbcParameters(String key, String value){
    this.parameters.put(key,value);
  }

  /**
   * This method read the value od jdbc parameters
   * @param key is the first jdbc parameter.
   * @return is the second jdbc parameter.
   */
  public String getJdbcParameters(String key){
    return (String)this.parameters.get(key);
  }

  /**
   * This method read the all jdbc parameters.
   * @return value of all jdbc parameters.
   */
  public Hashtable getAllParameters() {
    return this.parameters;
  }

  /**
   * This method sets the value of dbVendor parameter.
   * @param db_VendorName is value of parameter.
   */
  public void setDbVendor(String db_VendorName){
    dbVendorName=db_VendorName;
  }

  /**
   * This method read the value of dbVendor parameter.
   * @return value of parameter.
   */
  public String getDbVendor(){
    return dbVendorName;
  }

  /**
   * This method sets the value of driverName parameter.
   * @param driver_Name is value of parameter.
   */
  public void setDriverName(String driver_Name){
    driverName=driver_Name;
  }

  /**
   * This method read the value of driverName parameter.
   * @return value od parameter.
   */
  public String getDriverName(){
    return driverName;
  }


  /**
   * This method sets the value of strDriverClassName parameter.
   * @param driver_ClassName is value of the parameter.
   */
  public void setDriverClassName(String driver_ClassName){
    strDriverClassName=driver_ClassName;
  }

  /**
   * This method sets the value of strConnection parameter.
   * @param _connection is the value of the parameter.
   */
  public void setConnection(String _connection){
    strConnection=_connection;
  }
  /**
		* This method will set logger object
		* @param logger
		*/
	   private void setLogger() {
		   this.logger = StandardLogger.getCentralLogger();
	   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -