How do I connect to cockroachDB through JDBC from logstash output plugin?

By : ashivan
Source: Stackoverflow.com
Question!

I am using logstash to create a pipeline from Postgres to CockroachDB. Below is the config.

The input plugin(source is postgres) is working fine. But I am unable to establish a connection in the output plugin(cockroachDB) using JDBC. I am facing the below error.

JDBC - Connection is not valid. Please check connection string or that your JDBC endpoint is available. {:level=>:error, :file=>"logstash/outputs/jdbc.rb", :line=>"154", :method=>"setup_and_test_pool!"}

Destination(cockroachDB) is open for connection at the specified ip and port.

As cockroachDB JDBC connection string is very similar to postgres, I tried the below connection strings, and still the same error.

jdbc:postgresql://host/database
jdbc:postgresql://host/database?sslmode=disable
jdbc:postgresql://host:port/database
jdbc:postgresql://host:port/database?sslmode=disable

How do I connect to cockroachDB through JDBC from logstash output plugin?

By : ashivan


Answers

Your JDBC connection strings are OK.

Do not forget with JDBC the driver must be registered beforehand. You can do this either with Class.forName("org.postgresql.Driver") before your first JDBC class or invoke java.sql.DriverManager.registerDriver(new org.postgresql.Driver()); before you create your connection. Perhaps you forgot to register the driver?

By : kena




This video can help you solving your question :)
By: admin