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

查看:334
本文介绍了使用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)

推荐答案

来自

如果您收到以下例外之一:

If you receive one of the following exceptions:

  • com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms上的NullPointerException
  • IllegalArgumentException"InputStream不能为null",位于javax.xml.parsers.DocumentBuilder.parse,位于com.teradata.tdgss.jtdgss.TdgssParseXml.parse

那么问题可能是 由于未设置classpath或设置了classpath 错误地显示了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天全站免登陆