Solved

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

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

789 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