简体   繁体   中英

confluent jdbc-source-connector not working from Java

I have a jdbc-source-connector working when I run it from command line as below

bin/connect-standalone.sh \
    config/connect-standalone.properties \
    config/connect_mysql-jdbc-source.properties

but when I parse the file content into a map in a Java application and create an instance of io.confluent.connect.jdbc.JdbcSourceConnector with the map as argument I get

java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO )

Below is the content of my connector that, as I said, works when invoked from the command line and creates all the 3 topics

   name=test-mysql-jdbc   
   connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
   tasks.max=1
   connection.url=jdbc:mysql://127.0.0.1:3306/loaderDB 
   connection.user=root
   connection.password=MyPassword
   table.whitelist=loader_jobs, education_event, school_unit   
   tables="loader_jobs, education_event, school_unit"
   mode=bulk
   topic.prefix=test_mysql_jdbc_ 
   numeric.mapping=best_fit   
   poll.interval.ms=86400000 
   batch.max.rows=10000

When debugging the application I can clearly see that the all the properties are read and when it gets to the part to assign the connection url to get the database connection it throws the SQL exception above.

There is nowhere in that class any mention about the database user and password, so I tried changing the connection.url in the config file to

connection.url=jdbc:mysql://127.0.0.1:3306/loaderDB?user=root&password=MyPassword

but still I got the same Exception

I resolved the problem by upgrading my pom dependency as follow

    <groupId>io.confluent</groupId>
    <artifactId>kafka-connect-jdbc</artifactId>
    <version>5.0.0</version>

I was using version 2.0.1 earlier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM