Solved

Java app not able to connect to SQL Server, windows authentication

Posted on 2011-03-10
3
800 Views
Last Modified: 2012-05-11
I am trying to conenct from a java app to SQL Server with Windows authentication (not SQL Server one) but it fails.

Please see code below.
dbURL=jdbc:sqlserver://tst-server:1433;databaseName=my_DB;integratedSecurity=true;

 try
 {

       Class.forName(driverName);
    Connection dbConn = DriverManager.getConnection(dbURL);
    System.out.println("Connection Successful!");  
    // if successful print Connection Successful!
    return dbConn;

  }
 catch (Exception e)
 {
     e.printStackTrace();
     return null;
  }

I am receiving this error:
access denied (java.net.SocketPermission tst-eudqt:1433 connect,resolve)

If I use SSMS I can access the server and the db ;-)
0
Comment
Question by:miral13
  • 2
3 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 35095618
Are your NT credentials from workstation where you login to network added to SQL Server Security and have sufficient database access right for the same login?

0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 35095641
Also you should check all following:

1.First Check the port which we are given is free or not. If any other connection is using this then please specify other port.
2.Check the TCP/IP configuration in “MSSQL surface area configuration”. And if its disabled then make it enable.
3.Check the Windows Firewall. It may obstruct the port accessing. So please disable it or allow this port accessing through the firewall using windows firewall configuration.
4.Check if there is any antivirus software is running and it comes in between or not.
5.Check the Dynamic port allocation of SQL Server is set or not. If it sets to ZERO or any other port then make it ‘Blank’. [making Blank is important] Give the static port number we want to the port number place. These configurations we can do in “SQL Server Configuration manager”. Give IPALL = 1433 also.  This information will set in the following part of the windows registry HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Microsoft SQL Server> MSSQL.1 > MSSQLServer > SuperSocketNetLib > Tcp> IP1/IP2/IPALL. If it’s not changing there we can manually change it.
6.Then also its not working then please check the Windows Registry where we sets the “SQL Instance’s port number”. If it is different then please set that to our port number. It’s in HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Microsoft SQL Server > [Instance name] > MSSQLServer > SuperSocketNetLib > Tcp and change String value TcpPort = 1433.
0
 

Author Closing Comment

by:miral13
ID: 35209063
Point 5 did the trick. Thank you very much.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now