closing MYSQL JDBC connection in Spark
<p>I am loading data from MYSQL server to Spark through JDBC, but I need to close that connection after loading the data. What is the exact syntax for closing connection?</p>

<pre><code>df_mysql = sqlContext.read.format("jdbc").options(
  url="jdbc:mysql://***/****â,
  driver="com.mysql.jdbc.Driver",
  dbtable="((SELECT jobid, system, FROM Jobs LIMIT 500)  as T)",
  user=â*****â,
  password=â*****â).load()
</code></pre>

<p>I have tried dbtable.close(). That doesnt work.</p>

<p>There is really nothing to be closed here. <code>DateFrame</code> object is not a JDBC connection and <code>load</code> doesn't really <code>load</code> data. It simply fetches metadata required to build <code>DataFrame</code>.</p>

<p>Actual data processing takes place only when you execute a job which contains tasks depending on this particular input and is handled by the corresponding executors. There are responsible for managing connections and fetching data and this process is not exposed to the user.</p>

python mysql jdbc apache-spark pyspark