使用 Spark 从 teradata 表中读取数据时出现 ExceptionInInitializer 错误 [英] ExceptionInInitializer Error while Reading Data from teradata table using Spark

查看:26
本文介绍了使用 Spark 从 teradata 表中读取数据时出现 ExceptionInInitializer 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码从 teradata 读取数据但出现错误

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()

错误堆栈跟踪

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)

推荐答案

来自 Teradata JDBC 驱动程序文档:

如果您收到以下异常之一:

If you receive one of the following exceptions:

  • com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms 处的 NullPointerException
  • com.teradata.tdgss.jtdgss.TdgssParseXml.parse 中的 javax.xml.parsers.DocumentBuilder.parse 中的 IllegalArgumentExceptionInputStream 不能为 null"

那么问题可能是由于未设置类路径,或设置了类路径错误,导致找不到 tdgssconfig.jar.

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.

所以我猜在类路径中找不到 tdgssconfig.jar.

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

当然,如果 JDBC 驱动程序能够抛出比 NPE 更有用的错误消息,那就太好了.我有点担心这似乎是驱动程序的已知问题":我无法想象在这种情况下抛出更有用的异常会花费多少精力.如果他们选择记录这种行为而不是修复它,这对他们来说没什么意义.

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.

(致谢:通过 此 Teradata 社区帖子.)

这篇关于使用 Spark 从 teradata 表中读取数据时出现 ExceptionInInitializer 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆