confluentinc / kafka-connect-jdbc

Kafka Connect connector for JDBC-compatible databases
Other
21 stars 960 forks source link

MYSQL - JDBC Source Connector issues with schema.pattern #232

Open kvmkreddy opened 7 years ago

kvmkreddy commented 7 years ago

JDBC Source connector is not working with 'schema.pattern' in MySQL.

JDBC Source configurations:

name=test_source_connector
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector tasks.max=1 connection.url=jdbc:mysql://:3306/ connection.user= connection.password= mode=timestamp+incrementing incrementing.column.name=id timestamp.column.name=createdon topic.prefix=test table.whitelist=some_table schema.pattern=

Exception stack trace is as follows: [2017-06-13 22:43:06,057] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:99) java.lang.IllegalArgumentException: Number of groups must be positive. at org.apache.kafka.connect.util.ConnectorUtils.groupPartitions(ConnectorUtils.java:42) at io.confluent.connect.jdbc.JdbcSourceConnector.taskConfigs(JdbcSourceConnector.java:127) at org.apache.kafka.connect.runtime.Worker.connectorTaskConfigs(Worker.java:230) at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.recomputeTaskConfigs(StandaloneHerder.java:265) at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.updateConnectorTasks(StandaloneHerder.java:295) at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.putConnectorConfig(StandaloneHerder.java:182) at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:93)

It seems MySQL considering only schema name as catalog and not considering schema or schema pattern while fetching tables.

This returns all the tables in schema

ResultSet rs = con.getMetaData().getTables("", null, "%", null);

where as

ResultSet rs = con.getMetaData().getTables(null, "", "%", null);

returning none.

mayuanxiaonong commented 7 years ago

pattern is used in Oracle db. In Mysql, use catalog.

rhauch commented 6 years ago

See #333 for a different approach that uses catalog pattern and schema pattern, without having to explicitly set the catalog, which differs in different DBMSes. #333 hasn't yet been fully tested, and is still in progress.