Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-10
3
Medium Priority
?
813 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 40

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 40

Accepted Solution

by:
lcohan earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

916 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