MapReduce编程学习与mysq

白癜风微信群 http://www.lvyouxfnet.com/48774.html
前言:

我们本文的代码要实现的功能是从数据库读取数据,然后经mapReduce处理后,存储到数据库或文件系统。

MapReduce与关系型数据库(Mysql,Oracle)的数据交互,重点其实就是DBInputFormat和DBOutputFormat两个类。

准备数据:

(1)mysql中创建表salary(记录每个员工的收入款项),并插入数据

CREATETABLE`salary`(`id`int(11)NOTNULLAUTO_INCREMENT,`userId`int(11)NOTNULL,`money`decimal(10,2)NULLDEFAULTNULL,`sdate`datetime(0)NULLDEFAULTNULL,`mark`varchar()CHARACTERSETutf8mb4COLLATEutf8mb4_general_ciNULLDEFAULTNULL,PRIMARYKEY(`id`,`userId`)USINGBTREE)ENGINE=InnoDBAUTO_INCREMENT=7CHARACTERSET=utf8mb4COLLATE=utf8mb4_general_ciROW_FORMAT=Dynamic;INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(1,,.00,-02-:51:18);INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(2,,.00,-02-:51:6);INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(,,.00,-02-:51:49);INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(4,,.00,-02-:52:0);INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(5,,.00,-02-:52:21);INSERTINTO`test01`.`salary`(`id`,`userId`,`money`,`sdate`)VALUES(6,,.00,-02-:25:15);编写代码:

(1)编写实体用来封装db数据

package


转载请注明:http://www.xcqg58.com/lsqy/lsqy/26848220.html