sparkStreaming连接数据库(mysql)
2017-09-08 11:17
423 查看
通过SparkStreaming读取mysql数据库表数据jon另一张表
SparkConf conf = new SparkConf().setAppName("JDBCDataSource")
.setMaster("local");
JavaSparkContext sc = new JavaSparkContext(conf);
@SuppressWarnings("deprecation")
SQLContext sqlcontext = new SQLContext(sc);
// 分别将mysql中两张表的数据加载为dataset
Map<String, String> options = new HashMap<String, String>();
options.put("url", "jdbc:mysql://IP:3306/testdb");
options.put("driver", "com.mysql.jdbc.Driver") ;
options.put("user", "root");
options.put("password", "cys");
options.put("dbtable", "student_infos");
options.put("dbtable", "student_scores");
Dataset<Row> studentsInfosDS = sqlcontext.read().format("jdbc").options(options).load();
Dataset<Row> studentScoreDS = sqlcontext.read().format("jdbc").options(options).load();
。。。。t通过Dataset<Row> 的RDD对表数据join操作;
SparkConf conf = new SparkConf().setAppName("JDBCDataSource")
.setMaster("local");
JavaSparkContext sc = new JavaSparkContext(conf);
@SuppressWarnings("deprecation")
SQLContext sqlcontext = new SQLContext(sc);
// 分别将mysql中两张表的数据加载为dataset
Map<String, String> options = new HashMap<String, String>();
options.put("url", "jdbc:mysql://IP:3306/testdb");
options.put("driver", "com.mysql.jdbc.Driver") ;
options.put("user", "root");
options.put("password", "cys");
options.put("dbtable", "student_infos");
options.put("dbtable", "student_scores");
Dataset<Row> studentsInfosDS = sqlcontext.read().format("jdbc").options(options).load();
Dataset<Row> studentScoreDS = sqlcontext.read().format("jdbc").options(options).load();
。。。。t通过Dataset<Row> 的RDD对表数据join操作;
相关文章推荐
- Spark-SQL连接MySql关系型数据库
- Spark-SQL连接MySql关系型数据库
- sparkStreaming 连接数据库 --设计模式
- Spark SQL连接数据库找不到Mysql驱动解决方法
- spark 连接 mysql 数据库
- 第109讲: Spark Streaming电商广告点击综合案例动态黑名单基于数据库MySQL的真正操作代码实战
- sparkStreaming 连接数据库 --设计模式
- PHP使用数据库永久连接方式操作MySQL的是与非
- 执行Class.forName("com.mysql.jdbc.Driver");连接数据库时抛异常
- Node.js 连接 MySQL 并进行数据库操作
- 关于使用navicat for mysql在建立数据库连接时出现的2003 can't connect to mysql server on'localhost'(10038)问题
- JDBC连接mysql和各种数据库连接串
- PHP-数据库长连接mysql_pconnect的细节
- mysql/sqlserver/oracle安装以及设置远程连接数据库访问
- C#连接Access、SQL Server、Oracle、MySQL、DB2和SyBase六种不同数据库的程序源码
- Java连接MYSQL 数据库的连接步骤
- eclipse中数据库连接mysql配置
- 第114课(Scala版本)SparkStreaming+Kafka+Spark SQL+TopN+Mysql 电商广告点击综合案例实战
- 设置mysql用户密码(5.6/5.7)、远程连接数据库、常用命令
- 数据库操作:MYSQL与MFC连接(二)