apache / camel-kafka-connector-examples

Apache Camel Kafka Connector Examples
https://camel.apache.org
64 stars 43 forks source link

camel-kafka-connector-examples #330

Closed fywf555 closed 2 years ago

fywf555 commented 2 years ago

Open the SQL configuration file at $EXAMPLES/sql/sql-source/config/CamelSqlSourceConnector.properties

name=CamelSqlSourceConnector connector.class=org.apache.camel.kafkaconnector.sql.CamelSqlSourceConnector key.converter=org.apache.kafka.connect.storage.StringConverter value.converter=org.apache.kafka.connect.storage.StringConverter

topics=mytopic

camel.component.sql.dataSource.user=postgres camel.component.sql.dataSource.password=mysecretpassword camel.component.sql.dataSource.serverName=172.17.0.2 camel.component.sql.dataSource=#class:org.postgresql.ds.PGSimpleDataSource

camel.source.path.query=select * from accounts

Please tell me how to select database

i try to use

camel.component.sql.dataSource.serverName=172.17.0.2:5432/test

but faild

oscerd commented 2 years ago

You need to point to the address of an existing database. The address there is just an example

taobingqing commented 2 years ago

I can't find it either

oscerd commented 2 years ago

Read the Readme https://github.com/apache/camel-kafka-connector-examples/tree/main/sql/sql-source#setup-the-docker-image

oscerd commented 2 years ago

We write the Readme for this purpose

fywf555 commented 2 years ago

it is worked and use the default database; image

name=CamelSqlSourceConnector
connector.class=org.apache.camel.kafkaconnector.sql.CamelSqlSourceConnector
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.storage.StringConverter

topics=mytopic

camel.component.sql.dataSource.user=postgres
camel.component.sql.dataSource.password=ab.123456
camel.component.sql.dataSource.serverName=10.14.16.4:5432
camel.component.sql.dataSource=#class:org.postgresql.ds.PGSimpleDataSource
camel.source.path.query=select * from account

image

but i want to use another database,i try

name=CamelSqlSourceConnector
connector.class=org.apache.camel.kafkaconnector.sql.CamelSqlSourceConnector
key.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.storage.StringConverter

topics=mytopic

camel.component.sql.dataSource.user=postgres
camel.component.sql.dataSource.password=ab.123456
camel.component.sql.dataSource.serverName=10.14.16.4:5432/test
camel.component.sql.dataSource=#class:org.postgresql.ds.PGSimpleDataSource
camel.source.path.query=select * from invoice

and failed image

oscerd commented 2 years ago

Change the database nane according to the name you need to point. The error is clear

fywf555 commented 2 years ago

i understand....it a silly question

oscerd commented 2 years ago

No, it's not a silly question. We need to explain it better in the example. Let me improve the README.

oscerd commented 2 years ago

The commit should explain a bit better how to do it. Thanks for asking. We're always trying to improve the documentation.