001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.hadoop.mapred.lib.db; 020 021 import org.apache.hadoop.classification.InterfaceAudience; 022 import org.apache.hadoop.classification.InterfaceStability; 023 import org.apache.hadoop.mapred.JobConf; 024 025 /** 026 * @deprecated Use 027 * {@link org.apache.hadoop.mapreduce.lib.db.DBConfiguration} instead 028 */ 029 @Deprecated 030 @InterfaceAudience.Public 031 @InterfaceStability.Stable 032 public class DBConfiguration extends 033 org.apache.hadoop.mapreduce.lib.db.DBConfiguration { 034 /** The JDBC Driver class name */ 035 public static final String DRIVER_CLASS_PROPERTY = 036 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.DRIVER_CLASS_PROPERTY; 037 038 /** JDBC Database access URL */ 039 public static final String URL_PROPERTY = 040 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.URL_PROPERTY; 041 042 /** User name to access the database */ 043 public static final String USERNAME_PROPERTY = 044 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.USERNAME_PROPERTY; 045 046 /** Password to access the database */ 047 public static final String PASSWORD_PROPERTY = 048 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.PASSWORD_PROPERTY; 049 050 /** Input table name */ 051 public static final String INPUT_TABLE_NAME_PROPERTY = org.apache.hadoop. 052 mapreduce.lib.db.DBConfiguration.INPUT_TABLE_NAME_PROPERTY; 053 054 /** Field names in the Input table */ 055 public static final String INPUT_FIELD_NAMES_PROPERTY = org.apache.hadoop. 056 mapreduce.lib.db.DBConfiguration.INPUT_FIELD_NAMES_PROPERTY; 057 058 /** WHERE clause in the input SELECT statement */ 059 public static final String INPUT_CONDITIONS_PROPERTY = org.apache.hadoop. 060 mapreduce.lib.db.DBConfiguration.INPUT_CONDITIONS_PROPERTY; 061 062 /** ORDER BY clause in the input SELECT statement */ 063 public static final String INPUT_ORDER_BY_PROPERTY = org.apache.hadoop. 064 mapreduce.lib.db.DBConfiguration.INPUT_ORDER_BY_PROPERTY; 065 066 /** Whole input query, exluding LIMIT...OFFSET */ 067 public static final String INPUT_QUERY = 068 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_QUERY; 069 070 /** Input query to get the count of records */ 071 public static final String INPUT_COUNT_QUERY = 072 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_COUNT_QUERY; 073 074 /** Class name implementing DBWritable which will hold input tuples */ 075 public static final String INPUT_CLASS_PROPERTY = 076 org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_CLASS_PROPERTY; 077 078 /** Output table name */ 079 public static final String OUTPUT_TABLE_NAME_PROPERTY = org.apache.hadoop. 080 mapreduce.lib.db.DBConfiguration.OUTPUT_TABLE_NAME_PROPERTY; 081 082 /** Field names in the Output table */ 083 public static final String OUTPUT_FIELD_NAMES_PROPERTY = org.apache.hadoop. 084 mapreduce.lib.db.DBConfiguration.OUTPUT_FIELD_NAMES_PROPERTY; 085 086 /** Number of fields in the Output table */ 087 public static final String OUTPUT_FIELD_COUNT_PROPERTY = org.apache.hadoop. 088 mapreduce.lib.db.DBConfiguration.OUTPUT_FIELD_COUNT_PROPERTY; 089 090 091 /** 092 * Sets the DB access related fields in the JobConf. 093 * @param job the job 094 * @param driverClass JDBC Driver class name 095 * @param dbUrl JDBC DB access URL. 096 * @param userName DB access username 097 * @param passwd DB access passwd 098 */ 099 public static void configureDB(JobConf job, String driverClass, String dbUrl 100 , String userName, String passwd) { 101 102 job.set(DRIVER_CLASS_PROPERTY, driverClass); 103 job.set(URL_PROPERTY, dbUrl); 104 if(userName != null) 105 job.set(USERNAME_PROPERTY, userName); 106 if(passwd != null) 107 job.set(PASSWORD_PROPERTY, passwd); 108 } 109 110 /** 111 * Sets the DB access related fields in the JobConf. 112 * @param job the job 113 * @param driverClass JDBC Driver class name 114 * @param dbUrl JDBC DB access URL. 115 */ 116 public static void configureDB(JobConf job, String driverClass, String dbUrl) { 117 configureDB(job, driverClass, dbUrl, null, null); 118 } 119 120 DBConfiguration(JobConf job) { 121 super(job); 122 } 123 124 } 125