mapreduce计算的数据导入mysql出错,导入到本地都ok,哪位路过的大佬能帮忙看下

报错信息

Driver代码如下
package com.sky.cmcc.offlineComputeMR;

import com.sky.cmcc.pojo.MFee;
import com.sky.cmcc.pojo.RFee;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.db.DBConfiguration;
import org.apache.hadoop.mapreduce.lib.db.DBOutputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;

/**

  • Classname CmccDriver
  • Date 2019/9/29 11:08
  • Created by Teddys
  • Description 负责加载配置,启动MR,写入数据到mysql */ public class CmccDriver { // 定义msyql的四项 private static String DriverClass="com.mysql.jdbc.Driver"; private static String url="jdbc:mysql://localhost:3306/bot?characterEncoding=UTF-8"; private static String username="root"; private static String password="123456"; public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException { //1 加载配置文件和设定Job Configuration conf = new Configuration(); Job job = Job.getInstance(conf); //连接mysql DBConfiguration.configureDB(conf,DriverClass,url,username,password); //2 设置Job的加载路径 job.setJarByClass(CmccDriver.class); //3 指定job的mapper和reducer的类 job.setMapperClass(CmccMapper.class); job.setReducerClass(CmccReducer.class); //4 设置mqpper和最后的输出类型 job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(MFee.class); job.setOutputKeyClass(RFee.class); job.setOutputValueClass(NullWritable.class); //5 设置输入和输出的路径 FileInputFormat.setInputPaths(job,new Path(args[0])); //注意:输出路径为mysql DBOutputFormat.setOutput(job,"cmcc0513", "day","chargefee","shouldfee","orderCount","chargePayTime","chargeSuccessCount"); //6 提交任务,执行程序 boolean b = job.waitForCompletion(true); System.exit(b ? 0 : 1); System.out.println("b===="+b); } }

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问