0

I am using the below code to read data from teradata but getting error

val jdbcDF = spark.read
  .format("jdbc")
  .option("url",s"jdbc:teradata://${TeradataDBHost}/database=${TeradataDBDatabase}")
  .option("dbtable", TeradataDBDatabase+"."+TeradataDBTable)
  .option("driver","com.teradata.jdbc.TeraDriver")
  .option("user", TeradataDBUsername)
  .option("password", TeradataDBPassword)
  .load()

Error Stack Trace

Exception in thread "main" java.lang.ExceptionInInitializerError
            at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:577)
            at com.teradata.jdbc.jdbc.GenericTeraEncrypt.<init>(GenericTeraEncrypt.java:116)
            at com.teradata.jdbc.jdbc.GenericTeradataConnection.<init>(GenericTeradataConnection.java:107)
            at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:186)
            at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:36)
            at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)

Caused by: java.lang.NullPointerException
        at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<init>(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<clinit>(Unknown Source)
ZygD
  • 22,092
  • 39
  • 79
  • 102
Digvijay Waghela
  • 227
  • 1
  • 5
  • 15

1 Answers1

5

From the Teradata JDBC driver documentation:

If you receive one of the following exceptions:

  • NullPointerException at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms
  • IllegalArgumentException "InputStream cannot be null" at javax.xml.parsers.DocumentBuilder.parse, at com.teradata.tdgss.jtdgss.TdgssParseXml.parse

then the problem may be due to the classpath not being set, or the classpath being set incorrectly, such that tdgssconfig.jar cannot be found.

So I would guess that tdgssconfig.jar can't be found on the classpath.

Of course, it would be nice if the JDBC driver could have thrown a more helpful error message than an NPE. I am somewhat concerned that this appears to be a 'known issue' with the driver: I can't imagine it would take much effort to throw a more helpful exception in this situation. It doesn't say much for them if they have chosen to document this behaviour rather than fix it.

(Acknowledgement: found via this Teradata Community post.)

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104