PySpark jdbc错误,方法setProperty错误



在将数据写入oracle数据库时,我面临以下错误。我面临着下面的奇怪错误。

我不确定下面的问题是代码

self.batchsize = 50000
self.tgt_url = 'jdbc:oracle:thin:@' + self.tgt_hostname + ":" + self.tgt_port + "/" + self.tgt_schema
self.tgt_connectionProperties = {"user": self.tgt_username, "password": self.tgt_password,"driver": "oracle.jdbc.driver.OracleDriver", "batchszie": self.batchsize}
temp_table = self.TgtDatabase + "." + self.TgtTable
self.inmemdf.write.jdbc(self.tgt_url, table = temp_table , mode='append', properties=self.tgt_connectionProperties)
An error occurred while calling o171.setProperty. Trace:
py4j.Py4JException: Method setProperty([class java.lang.String, class java.lang.Integer]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
at py4j.Gateway.invoke(Gateway.java:274)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:748)

我最初认为这是数据问题,甚至还将数据转换为目标数据类型。无法理解此是什么类型的错误

  1. 如果代码"batchszie": self.batchsize中有拼写错误,应该是"batchsize": self.batchsize
  2. self.batchsize的类型是Integer,而错误表明没有(String,Integer(的方法,所以只需将其更改为String:
self.batchsize = '50000'

最新更新