Certificate Exception connecting to Azure SQL with JDBC with default connection string (the one the management console says to use) - jdbc

I'm wanting to connect to an Azure SQL Server from jdbc.
I copy the connection string from the azure management console. It is something like:
jdbc:sqlserver://XXXX.database.windows.net:1433;database=YYYY;user=ZZZZZ#XXXX;password=PPPPPPPPPPP;encrypt=true;hostNameInCertificate=*.database.windows.net
When I try and connect with this value I get the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not
establish a secure connection to SQL Server by using Secure Sockets
Layer (SSL) encryption. Error:
"java.security.cert.CertificateException: Failed to validate the
server name in a certificate during Secure Sockets Layer (SSL)
initialization. The server name is *.database.windows.net, the name in
certificate is data.am2-1.database.windows.net.
Then if I change the *.database.windows.net to data.am2-1.database.windows.net as it says in the exception it works fine.
So is it a problem to set this name? I feel like if it is a wild card as default then it is probably going to change? and when it does I assume I won't be able to connect anymore.
Has anyone else had this issue? I am using the most up to date jdbc drivers for SQL Server that I could find.

Turns out an upgrade of the sql server jdbc version to version 4.0 cleaned up the issue.

I've got the same issue on JDBC driver version 4.1, downgrading to 4.0 resolved issue

You can also add trustServerCertificate=true in your connection string, but it's not recommended from a security perspective.

Related

Export Database connection to Oracle Developer

I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.

java.sql.SQLException: ORA-28040: No matching authentication protocol DSRA0010E: SQL State = 99999, Error Code = 28,040

I am trying to change the datasource in WebSphere pointing to some other environment. I am able to connect it using toad or sqldeveloper. However when I am trying to test the connection from websphere, it is giving the following error.
"java.sql.SQLException: ORA-28040: No matching authentication protocol DSRA0010E: SQL State = 99999, Error Code = 28,040. View JVM logs for further details."
I tried restarting the server but didn't helped. Not sure what is going wrong in this.
You didn't post any configuration information or server logs, so, assuming the old Oracle connection URL was working prior to you changing it, one common cause of this problem is changing the connection URL to move from an Oracle 11 instance (or earlier) to an Oracle 12 instance without properly updating the classpath of the WebSphere JDBC Provider to use at least the ojdbc6.jar.

How to connect Neo4j JDBC driver with DbVisualizer

I am running Neo4j 2.1.6, tried Neo4j 2.20 as well.
I can not connect it with DbVisualizer 9.1.13
And I can not find ANY step by step clear explanation on how to do it.
First I've got binary JDBC Neo4j-2.0.1-SNAPSHOT here
I can run my just installed Neo4j instance from the browser localhost:7474
and I don't know what the REST API is all about and if it is turned on by default.
I can run the Neo4j 2.20 same way that comes with a new feature of user authorization and I am not sure if that JDBC driver is compatible with it. My user:pass is neo4j:neo
So in DbVisualizer I clicked Tools->Driver Manager and filled out like this:
My connection properties are as follows:
I've got the error on connect:
Product: DbVisualizer Pro 9.1.13
Build: #2310 (2015-01-11 11:26:27)
Java Version: 1.8.0_25
OS Name: Windows Server 2012 R2
An error occurred while establishing the connection:
The selected Driver cannot handle the specified Database URL.
The most common reason for this error is that the database URL
contains a syntax error preventing the driver from accepting it.
The error also occurs when trying to connect to a database
with the wrong driver.
If you look at the documentation for the jdbc driver, you see that the database URL is:
jdbc:neo4j://localhost:7474/
Please try to make it work with 2.1.6 first.
For the 2.2. auth you have to use the token you got back as password.

How to sniff Oracle's credentials from a connection attempt to the database?

I have a legacy application, which connects to the configured Oracle database.
It seems it has some logic that alters the database credentials as it is unable to successfully log in to the Oracle database, while sqlplus started on the same machine is able to log in.
The error I am getting is: [DataDirect][ODBC Oracle Wire Protocol driver][Oracle]ORA-01017: invalid username/password; logon denied
How to find out what is the database username and password that are sent to the database?
What I have tried so far:
Enabled auditing of failed sign-on attempts on Oracle (audit create session whenever not successful). It does not solve the issue, because it only logs the username, which seems to be correct, without the password.
Used a sniffer to eavesdrop the network traffic between the machine running the application and the database, but since Oracle's TNS protocol is encrypted, it did not help a lot.
Started a server using netcat on port X, provided port X in the application configuration file. The application did connect to my server, that is how I know the application is connecting to the correct server. But since the TNS protocol is pretty complex (requires a series of messages to be exchanged between the client and the server) I hope there is a simpler why of achiving what I want without having to reverse engineer Oracle and implementing my own server.
Enabled tracing of the JDBC driver (Trace=1, TraceFile, TraceDll). The trace file shows the correct username, but obviously the password is not getting logged.
My environment:
Database: Oracle 11g
Application runs on: Solaris
Application uses: DataDirect ODBC Oracle Wire Protocol v70
I not sure, but if connection established by ODBC driver (as described in question tags) then you can try ODBC sniffing tools like ODBC Tracing.
Citation:
Password "Sniffing" Using Trace
ODBC provides a means for tracing the conversation taking place between the driver and the host database. Used by developers for testing purposes, the tracing feature is designed to help programmers find out exactly what is going on and to help fix problems. However, tracing (also called "sniffing") can be used by nefarious bad guys to retrieve user passwords.
When tracing is enabled, communications with the host are written to a file. This includes the user ID and password, which are captured in plain text.
Update
SQLPlus connects to Oracle with OCI interface, but DataDirect ODBC driver uses it's own proprietary implementation of communication protocol. So, most probable point of failure is driver misconfiguration or incompatibility.
DataDirect provides some tools for ODBC drivers diagnostics, but only option applicable to case described in question is using snoop utility, which acts like a netcat which already tried.
Because connection failed at credential verification stage, the most probable source of error is using localized symbols for user name or password. There are some issues with Oracle authentication process, listed in DataDirect Knowledge Search (search for ORA-01017).
It seems that DataDirect provides two separate version of driver with and without Unicode support, therefore one of possible points of failure is to connecting with non-Unicode version of driver to Unicode version of database and vice verse.
P.S. For now I don't have any experience with DataDirect ODBC driver. So it's only suggestions about possible source of failure.

Error to connect with SQL Server

I have Runtime error that "Not associated with trusted SQL server connectiion" Please help me
This usually happens when you try to connect to a SQL Server db that has been set up with Windows Only Authentication (not Windows and SQL Server Authentication)...That can be changed if you have access to the DB.
See: http://decipherinfosys.wordpress.com/2008/11/14/the-user-is-not-associated-with-a-trusted-sql-server-connection/
Sounds like an authentication error with the SQL server. Check your connection string and your SQL server's authentication settings.
More info here, and of course here.

Resources