Solved

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

Posted on 2011-03-10
3
802 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query 2 59
How to run sql statements from SQLCMD or command line 2 54
SQL 2005 - Memory Table Column Names 11 68
My Query is not giving correct result. Please help 5 27
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

23 Experts available now in Live!

Get 1:1 Help Now