pyspark jdbc错误,方法setproperty错误

oxalkeyp  于 2021-07-14  发布在  Spark
关注(0)|答案(1)|浏览(300)

我在将数据写入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)

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

fnx2tebb

fnx2tebb1#

你的代码有错 "batchszie": self.batchsize ,应该是
"batchsize": self.batchsize self.batchsize 是integer类型,而错误说明没有(string,integer)的方法,所以只需将其更改为string:

self.batchsize = '50000'

相关问题