package spark import java.util.Properties import org.apache.spark.sql.SQLContext import org.apache.spark.{SparkContext, SparkConf} import spark.bean.orders object SelectFromOneTable { def main(args: Array[String]) { val sparkConf = new SparkConf().setAppName("Spark SQL Test Case").setMaster("local") val sparkContext = new SparkContext(sparkConf) val sqlContext = new SQLContext(sparkContext) val properties = new Properties() val url = "jdbc:mysql://localhost:3306/sun_test?user=root&password=123"; val prop = new Properties() val df = sqlContext.read.jdbc(url, "flow", prop).collect() for( a <- df ){ println(a) } } }