val conf=new SparkConf().setAppName("JdbcRDDDemo").setMaster("local[2]")
val sc=new SparkContext(conf)
def getConnection()={
Class.forName('com.mysql.jdbc.Driver').newInstance()
DriverManager.getConnection("jdbc:mysql://localhost:3306/bigdata","root","123");
}
val jdbcRDD=new JdbcRDD(sc,getConnection,"SELECT * FROM ta where id >= ? AND id <=?",1,4,2,rs=>{...})
Spark操作数据库
最新推荐文章于 2023-07-25 10:26:44 发布