使用Spark从Teradata表读取数据时发生ExceptionInInitializer错误

编程入门 行业动态 更新时间:2024-10-28 21:15:27
本文介绍了使用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
  • 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错误

本文发布于:2023-10-22 23:46:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519093.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   发生   数据   Spark   Teradata

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!