oracle的驱动程序

brjng4g3  于 2021-06-04  发布在  Kafka
关注(0)|答案(2)|浏览(706)

我正在尝试在kafka中以独立模式使用oraclejdbc8(ojdbc8.jar)运行oracle源代码连接器。我已经从oracle网站下载了confluent的JDBCjar和ojdbc8.jar。我已经在本地测试过了,效果很好,但是在我们的测试环境中,它抛出了以下错误:

No suitable driver found for jdbc:oracle:thin:@x.x.x.x:yyyy:zzz for configuration Couldn't open connection to jdbc:oracle:thin:@x.x.x.x:yyyy:zzz

完整错误消息:

ERROR Failed to create job for xyz/xyz.properties (org.apache.kafka.connect.cli.ConnectStandalone:110)
[2020-03-11 13:13:32,085] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:121)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector configuration is invalid and contains the following 2 error(s):
Invalid value java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@x.x.x.x:1521:xyz for configuration Couldn't open connection to jdbc:oracle:thin:@x.x.x.x:1521:xyz
Invalid value java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@x.x.x.x:1521:xyz for configuration Couldn't open connection to jdbc:oracle:thin:@x.x.x.x:1521:xyz

插件的路径也很好,因为它正在注册所有jar。我尝试了一些我在网上找到的修复方法,包括将插件路径放在classpath变量中。它不起作用,抛出了前面提到的错误。我也能ping和telnet的ip和端口分别。
我的连接器配置如下:

name=oracle-jdbc-connect
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
connection.url=jdbc:oracle:thin:@x.x.x.x:yyyy:zzz
connection.user=xyz
connection.password=xyz
query=SELECT cast(ID AS NUMBER(7, 0)) AS ID, NAME FROM sch.tbl
mode=incrementing
incrementing.column.name=ID
topic.prefix=topic-test
schema.pattern=sch
numeric.mapping=best_fit
dialect.name=OracleDatabaseDialect
timestamp.delay.interval.ms=5000
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=false
value.converter.schemas.enable=false
decimal.handling.mode=double
include.schema.changes=false

不过,此处给定的connection.user在oracle中具有“只读”权限。这会是个问题吗?
connect-standalone.properties文件如下:

key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=true
value.converter.schemas.enable=true
offset.storage.file.filename=/tmp/connect.offsets
offset.flush.interval.ms=10000
rest.host.name=x.x.x.x
rest.port=8877 # Some random port
plugin.path=/home/plugins/,/usr/share/java,/usr/local/share/kafka/plugins

oracle版本:18c
Kafka版本:2.3.0
scala版本:2.12.2
plugins.path:/home/plugins
插件路径结构:/home/plugins/connectors/[assets、docs、lib等文件夹],ojdbc8.jar。
在/home/plugins/connectors/lib中,我有kafka-connect-jdbc-5.4.0.jar文件。

kse8i1jr

kse8i1jr1#

如果您使用的是java11,请更新到ojdbc10。对于kafka,ojdbc8与java8兼容,ojdbc10与java11兼容。

krcsximq

krcsximq2#

你的 ojdbc8.jar 需要与kafka connect jdbc jar位于同一文件夹中。
所以如果kafka connect jdbc jar在 /home/plugins/connectors/lib 然后把 ojdbc8.jar 也在里面。

相关问题