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

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?

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?

For posterity, this should be working now. The problem was that JDBC's isValid() method was failing due to CockroachDB failing to prepare empty statements, which has since been fixed in CockroachDB.

Related

Database connection failed with JDBC to SAP Hana

I'm currently trying to test a JDBC connection to SAP Hana with AWS Glue.
Testing the connection results in the following error message:
com.amazonaws.glue.jobexecutor.commands.exception.CommandExecutorException: java.lang.IllegalArgumentException: No enum constant com.amazonaws.glue.jobexecutor.commands.jdbc.SupportedDriver.SAP
My JDBC URL looks like that jdbc:sap://ip:port/?databaseName=tdb
After looking in the developer guide from AWS for the JDBC Connection Properties, it looks like that required protocol for hana is not a supported right now.
So is this the case that you currently can't connect to a SAP Hana database with AWS Glue or am I missing something in my connection configuration?
The HANA JDBC driver seems not to be supported at the moment. AWS describes a way via S3, that, depending on your requirements might be enough for you:
https://aws.amazon.com/de/blogs/awsforsap/extracting-data-from-sap-hana-using-aws-glue-and-jdbc/

JBAS010447: Connection is not valid

I need help, when i try to create a datasource connection on jboss show this error JBAS010447: Connection is not valid
my connection url is jdbc:oracle:thin:#//localhost:1521/ORCL
on my jboss log show ORA-28040: No matching authentication protocol
I think your JDBC driver and Oracle Database version are not suitable. Please check your ojdbc.jar Check this link

Does Hikari Connection need test connection when starts the application?

I configured Hikari following this tutorial: https://www.baeldung.com/spring-boot-hikari
When Spring Boot starts Hikari starts too, as follows in the next image:
Is it possible to configure Hikari to start when the first ReST request is being received?
Quoted from Hikari's official document on Github:
connectionTestQuery
If your driver supports JDBC4 we strongly recommend not setting this property. This is for "legacy" drivers that do not support the JDBC4
Connection.isValid() API. This is the query that will be executed just
before a connection is given to you from the pool to validate that the
connection to the database is still alive. Again, try running the pool
without this property, HikariCP will log an error if your driver is
not JDBC4 compliant to let you know. Default: none
As documentation:
"For a pooling DataSource to be created, we need to be able to verify that a valid Driver class is available, so we check for that before doing anything. In other words, if you set spring.datasource.driver-class-name=com.mysql.jdbc.Driver, then that class has to be loadable."(https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/)

How to connect to Teradata using SoapUI? What are the configuration details for SoapUI-Teradata connection?

I want to add a test step in Soap UI Test Case, wherein I can connect to Teradata database and fire a query to validate.
However, I am facing issues while setting up the configuration for the connection.
In the configuration details, I have provided as below:
Driver: com.teradata.jdbc.TeraDriver
Connection String: jdbc:teradata:
Below is the error thrown on TEST CONNECTION:
Can't get the Connection for specified properties; java.sql.SQLException:
[Teradata JDBC Driver] [TeraJDBC 15.10.00.35] [Error 1032] [SQLState HY000]
Single Sign-On NOT supported for Mechanism TD2.
Note:
1. I have NOT added any properties(Name/Value).
2. SoapUI 5.3.0. (Free) version.
3. Teradata drivers(terajdbc4, tdjssconfig jars) are added in ../SmartBear/SoapUI-5.3.0/bin/ext/
I figured it out. Here is the solution.
Driver=com.teradata.jdbc.TeraDriver
Connection String=jdbc:teradata://servername/USER=username,PASSWORD=password
The issue was with incorrect syntax for Connection String.
Thanks all for your inputs!

jdbc connection "alternative to Class.forname for driver loading"

can we use anything else instead of Class.forName() for loading a driver for jdbc connectivity
i.e is first step of jdbc connection?
can we use anything else instead of "Class.forname" for loading a driver for jdbc connectivity i.e is first step of jdbc connection?
You haven't even needed that since JDBC 4.1. Just call DriverManager.getConnection() with an appropriate URL.
Just import java.sql.Driver and invoke DriverManager.getConnecion() to establish a database connection. You don't really need to call Call.forName() these days (java7).

Resources