I am trying to jdbc but its giving me error. Can s...

Discussion in 'Big Data and Analytics' started by _31353, Jul 9, 2018.

  1. _31353

    _31353 Member

    Joined:
    May 4, 2018
    Messages:
    4
    Likes Received:
    0
    I am trying to jdbc but its giving me error. Can someone please see how to solve this.
    scala> val properties = new java.util.Properties
    properties: java.util.Properties = {}

    scala> properties.put("user","labuser")
    res3: Object = null

    scala> properties.put("password","simplilearn")
    res4: Object = null

    scala> properties.put("driverClass","com.mysql.jdbc.Driver")
    res5: Object = null

    scala> val url = "jdbc:mysql://localhost:3306/retail_db"
    url: String = jdbc:mysql://localhost:3306/retail_db

    scala> val table = "customers"
    table: String = customers

    scala> val cust = spark.read.jdbc(url,table,properties)

    java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getDriver(DriverManager.java:315)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:84)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:84)
    at scala.Option.getOrElse(Option.scala:121)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:83)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:34)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:32)
    at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:306)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:146)
    at org.apache.spark.sql.DataFrameReader.jdbc(DataFrameReader.scala:193)
    ... 48 elided
     
    #1
  2. Shalini Rana

    Shalini Rana Well-Known Member
    Simplilearn Support

    Joined:
    Jul 24, 2017
    Messages:
    304
    Likes Received:
    16
    Hi Learner,

    We would like to inform you that, you are using the incorrect URL for JDBC connection. Please find the correct link below:

    val url = "jdbc:mysql://ip-10-0-1-10.ec2.internal/retail_db"

    Thanks,
    Shalini
     
    #2

Share This Page