Unable to get connection from MSSql while trying with Spring Data R2DBS - sql-server

I am using Spring Data R2DBS for MSSQL db.
I am trying to connect to an instance using Windows Authentication with JavaKerberos authentication, instead of some SQL Authentication.
When I am trying with JDBC using below property, I am able to get a connection:
spring.datasource.url=jdbc:sqlserver://AAAAAA.bb.myapp\\ZZZZZ;databaseName=mydb;integratedSecurity=true;authenticationScheme=JavaKerberos
But when I am trying below property using R2dbs, I am getting the below exception:
spring.r2dbc.url=r2dbc:mssql://AAAAAA.bb.myapp\\ZZZZZ;databaseName=mydb;integratedSecurity=true;authenticationScheme=JavaKerberos
Below is the exception am getting while trying with Spring Data R2dbc:
Caused by: java.net.URISyntaxException: Illegal character in authority at index 8: r2dbc://AAAAAA.bb.myapp\ZZZZZ;databaseName=mydb;integratedSecurity=true;authenticationScheme=JavaKerberos
at java.base/java.net.URI$Parser.fail(URI.java:2974) ~[na:na]
Can anyone please tell me how to fix for above issue?

Related

How can we connect to snowflake using DB Visualizer using Azure AD

I am using the following Database URL in DB Visualizer to connect to snowflake using Azure AD authentication
jdbc:snowflake://accountname.snowflakecomputing.com/?authenticator=externalbrowser&warehouse=xxxxx_WH&db=xxx_db&schema=xxxx_schema
I am getting the following error : JDBC driver encountered communication error. Message: Exception encountered for HTTP request: sun.security.validator.ValidatorException: No trusted certificate found.
This error is usually indicating that the jvm can't find the necessary certificates. You can refer to the following link for further troubleshooting:
https://community.snowflake.com/s/question/0D50Z00009LHQMSSA5/how-do-i-resolve-no-trusted-certificate-found-error-when-connecting-to-snowflake-via-jdbc-driver-in-java
See if you can export JAVA_HOME to match the jdk installation where your cacerts is located. It is usually located under <JAVA_HOME>/lib/security/cacerts.
-pd

Error when connecting to Snowflake REST request for URL failed

I am receiving the below error when trying to establish connection to Snowflake. I am working on to load data from the SQL server tables to Snowflake tables via SSIS. I have set up the ODBC connection and connecting through a proxy, entered the proxy name in the DSN. Any help appreciated, thanks in advance!
Error: REST request for URL https:.//abc.azure.snowflakecomputing.com failed : CURL error (curl_easy_perform() failed) - code=56 msg = 'Failure when receiving data from the peer"'
(renamed actual account name to abc for security purposes)
This refers to the JDBC driver not being able to be found in the JAVA classpath.
There are two ways of pointing to the location of the JDBC jars
https://docs.snowflake.com/en/user-guide/spark-connector-install.html#label-spark-cluster-setup
Create a JAVA_CLASSPATH variable and update the locations of the spark jars and JDBC jars.

Snowflake .net connector certificate error

I am having trouble using .net connector (https://github.com/snowflakedb/snowflake-connector-net). It works from browser/Tableau/Excel. For tableau/excel I have to pass CaBundleFile.
Is there a way to pass a certificate file (CaBundleFile) using the .net connector?
I am getting following error.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not
establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Unlike the ODBC driver, Snowflake doesn’t perform OCSP checking for .NET driver which uses the underlying .NET framework for checking validity of the HTTPS certificate.
One thing that might help is looking through similar GitHub issues for ideas (they discuss upgrading and network traces):
https://github.com/snowflakedb/snowflake-connector-net/issues/6
You might also try looking at some of the Microsoft docs and forums for the error on some troubleshooting ideas:
https://learn.microsoft.com/en-us/archive/blogs/jpsanders/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure

How to connect to sql DB from soapUI using connection string?

I would like to ask someone who already tried to connect to SQL database from soapUI opensource version.
I have a test step JDBC request where I try to test and connect to my sql database. I use opensource version of soapUI. I read how it should be set up but still experience some problems.
This is what I do:
I installed java 8 and jdbc driver version 4.1. Added jdbc jar file to SoapUi/jre/bin folder as it is said in documentation for soapUI. This version of driver should work with Java 8.
Then in Driver field I write
com.microsoft.sqlserver.jdbc.SQLServerDriver
In connection string:
jdbc:sqlserver://Sservername:portnumber;databaseName=Consumption;username=alyona.kovalyova;password=mypassword
I get error saying
Can't get the Connection for specified properties; com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'alyona.kovalyova'. ClientConnectionId...
I use my domain account because in our company the policy does not allow us to use database user. Because of this I tried to add integratedSecurity parameter to the string which should allow to login with windows account like this:
jdbc:sqlserver://S23-AS:1433;databaseName=Consumption;integratedSecurity=true
I also get error:
Can't get the Connection for specified properties; com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId..
Does anyone encountered the same issue before? Could you give some recommendation?
For integrated authentication to work you'll need sqljdbc_auth.dll matching your environment (32bit / 64bit) in your library path (putting it in bin as well might help already)

Datasource to SQL Server does not work in websphere

We are using in our project a websphere application server and want to connect to a sql server. In our websphere we have configured a datasource and the testing of the connection in the websphere works. In our deployed application the connection does not work. We get this exception:
Caused by: com.ibm.websphere.ce.cm.StaleConnectionException: Single-Sign-On is only supported on Windows. Please specify a user name.DSRA0010E: SQL State = 08001, Error Code = 0
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:515)
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper(GenericDataStoreHelper.java:608)
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:670)
at com.ibm.ws.rsadapter.AdapterUtil.mapException(AdapterUtil.java:2111)
at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getPooledConnection(WSRdbDataSource.java:2320)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1600)
at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2036)
at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1713)
at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:2496)
at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1063)
at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:700)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:668)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:635)
at de.volkswagen.dps.server.core.database.ConnectionFactory.createDatasourceConnection(ConnectionFactory.java:45)
... 40 more
We use this driver: jtds-1.2.4.jar which we got from here
Have anybody an idea how to solve the problem?
Looks like a security issue.
With Test Connection a SSO (Single sign on) can be used, but not in the deployed app.
you need to make sure you setup a JAAS authentication alias and configure your Datasource to use it, that alias comtains the username and password to be used for authentication.
Open the Datasource in the admin console and there is a link on the right to create the JAAS alias and tHere are combo boxes to tell the datasource to use it.

Resources