You can load data from an external data source which supports Java Database Connectivity (JDBC). Using a JDBC driver, you can connect to a relational database such as Mysql and load the content of a table into Spark as shown in in the following code snippet:
sqlContext.load(path=None, source=None, schema=None, **options)
The following is an example of loading from a JDBC datasource:
val dbContent = sqlContext.load(source="jdbc", url="jdbc:mysql://localhost:3306/test", dbtable="test", partitionColumn="id")