Skip to content

Commit 73d0614

Browse files
committed
[SPARK-6966][SQL] Use correct ClassLoader for JDBC Driver
1 parent 3ae37b9 commit 73d0614

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/jdbc/JDBCRelation.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package org.apache.spark.sql.jdbc
2020
import java.sql.DriverManager
2121
import java.util.Properties
2222

23+
import org.apache.spark.util.Utils
24+
2325
import scala.collection.mutable.ArrayBuffer
2426

2527
import org.apache.spark.Partition
@@ -99,7 +101,7 @@ private[sql] class DefaultSource extends RelationProvider {
99101
val upperBound = parameters.getOrElse("upperBound", null)
100102
val numPartitions = parameters.getOrElse("numPartitions", null)
101103

102-
if (driver != null) Class.forName(driver)
104+
if (driver != null) Utils.getContextOrSparkClassLoader.loadClass(driver)
103105

104106
if (partitionColumn != null
105107
&& (lowerBound == null || upperBound == null || numPartitions == null)) {

0 commit comments

Comments
 (0)