Understanding the Spark JDBC API
JDBC is a specification for an application programming interface (API) that allows Java applications to access databases. A JDBC driver is an actual implementation of the specification for a given database.
In order to work with databases, we need to understand the JDBC API offered by Spark. This section will explore the Spark JDBC API in detail by going through several examples.
To begin with, let’s take a look at the interface provided by Spark. The following example is inspired by the Spark documentation and shows a basic template for creating a DataFrame using a database table:
val jdbcDF = spark.read     .format("jdbc")     .option("url", "jdbc:postgresql:dbserver")     .option("dbtable", "schema.tablename")     .option("user", "username")     .option("password...