yrz
yrz

Reputation: 57

Glassfish connection to MS SQL server database

I have evaluation copy of MS SQL server installed with database AdventureWorks2016 attached to it and have run Glassfish on localhost:4848. TCP/IP connection is allowed on SQL server (Configuration Manager) and TCP port is 1433. I have downloaded Microsoft JDBC Driver 7.0 for SQL Server from Microsoft JDBC Driver and unzipped it in C:\ and set a CLASSPATH variable to point to it and have placed a copy of it in C:\Program Files\glassfish5\glassfish\domains\domain1\lib. I use Windows Authentication to connect to MS SQL server. I create AdventureWorks2016 connection pool with all defaults. When I ping it, I am getting

java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.(Lsun/security/ssl/ProtocolVersion;Lsun/security/ssl/CipherSuite;Ljava/util/Collection;Lsun/security/ssl/SessionId;Ljava/lang/String;I)V sun.security.ssl.SSLSessionImpl.(Lsun/security/ssl/ProtocolVersion;Lsun/security/ssl/CipherSuite;Ljava/util/Collection;Lsun/security/ssl/SessionId;Ljava/lang/String;I)

What am I missing? java jdk is java 8 (jdk1.8.0_191) and Glassfish 5.0.

I have downgraded to java8u151. Now the error, when I am pinging is :

Ping Connection Pool failed for AdventureWorks2016. Connection could not be allocated because: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Unsupported curveId: 29". ClientConnectionId:ebe27ff7-0ce1-4e9d-95fd-52133be8ee01 Please check the server.log for more details.

As I have said, I am using Windows Authentication on the server, because I do not need anything else on my laptop and because this has worked first, when I installed MS SQL Server. Now I try

jdbc:sqlserver://localhost;integratedSecurity=true;

for the URL property, but it did not have an effect.

Upvotes: 1

Views: 3588

Answers (4)

fleed
fleed

Reputation: 680

You have to use a specific version of JDK for this to work: 181. I could only get this to work consistently with the MS SQL Server JDBC driver if I use JDK version 181. I wish there was a better way of using more up to date version of JDK but unfortunately this is it.

Upvotes: 0

The answer given by @VinnhCC solve the problem if you put the option in 'server-config' instead 'default-config'.

Upvotes: 1

Vinh Can Code
Vinh Can Code

Reputation: 437

The prolem "Unsupported curveId: 29" was solved.

Here is my setting in Glassfish (Java8 build 152):"-Dcom.sun.net.ssl.enableECC=false".

See the image: enter image description here

Upvotes: 3

Mike
Mike

Reputation: 4963

You are hitting a known issue with GlassFish 5.0 and Java versions higher than 8u161.

from the last time I answered this problem:

The solution to this is to downgrade your version of Java to a version below 8u161.

I answered this in more detail in another answer but, if you do not like the idea of downgrading Java, you could either use the latest GlassFish 5.0.1 nightly or switch to Payara 5, which is derived from GlassFish and should work the same in most cases.

Edit: Note that, after making one of these changes, you will still need to add a security exception so that your browser accepts the self-signed certificate, but the page should work with no further issues; I verified this myself with Java 8u144

Upvotes: 1

Related Questions