srowen commented on a change in pull request #23464: [SPARK-26383][Core] - NPE 
when use DataFrameReader.jdbc with wrong URL
URL: https://github.com/apache/spark/pull/23464#discussion_r245514964
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
 ##########
 @@ -60,7 +61,13 @@ object JdbcUtils extends Logging {
         throw new IllegalStateException(
           s"Did not find registered driver with class $driverClass")
       }
-      driver.connect(options.url, options.asConnectionProperties)
+      val connection: Connection = driver.connect(options.url, 
options.asConnectionProperties)
+
+      if (connection == null) {
 
 Review comment:
   Use `require(connection != null, ...)`. I'd also change the message and 
scaladoc to be a little more general, like here: `s"The driver could not open a 
JDBC connection. Check the URL: ${options.url}"`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to