python - 带有方法 setProperty 错误的 PySpark jdbc 错误
问题描述
将数据写入 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)
我最初认为这是数据问题,甚至还将数据转换为目标数据类型。无法理解这是什么类型的错误
解决方案
- 您的代码中有错字
"batchszie": self.batchsize
,应该是"batchsize": self.batchsize
self.batchsize
是Integer类型的,而错误说没有(String,Integer)的方法,所以只需将其更改为String:
self.batchsize = '50000'
推荐阅读
- php - 通过键和值 PHP 对多数组进行分组
- javascript - 数据验证 - 正确显示密码要求
- javascript - Babel preset minify TypeError: _interopRequireDefault is not a function
- python - 为什么没有检测到我的 urls.py 文件?
- java - 如何在 Java Web 代码中编写 Python 3 代码?
- apache - 为什么 localhost 显示“它有效!” 而不是我的文件?
- recursion - SML - 生成列表所有可能组合的函数
- reactjs - Firebase:从嵌套的 onSnapshot 获取数据时出现问题
- python-3.x - 如何动态设置 tkinter 标签的名称
- nginx - 如何根据配置更改更新 kuberenet pod?