'Error reading data from DB2 table in Spark

I'm trying to read data from DB2 table using spark jdbc, but getting the below error.

Exception in thread "main" com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=*;SELECT * FROM select;UNION, DRIVER=4.19.26

Code:

val df = spark.sqlContext.read.format("jdbc")
      .option("driver", "com.ibm.db2.jcc.DB2Driver")
      .option("url", "jdbc:db2://server/database")
      .option("user", "user")
      .option("password", "password")
      .option("dbtable","select * from schema.table limit 10").load()

Any help is appreciated. Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source