Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Windows authentication

Author  Topic 

spillo491
Starting Member

3 Posts

Posted - 2010-09-09 : 10:50:33
Can you help me with correct java code to connect to sql server with windows authentication ?

dbUrl=jdbc:jtds:sqlserver://192.168.3.6:1099/db_test;instance=test
Connection con = DriverManager.getConnection( dbUrl, "", "" );

Sql server and web server (tomcat on my machine) are on the same local network !

Thank you
Regards

RobertKaucher
Posting Yak Master

169 Posts

Posted - 2010-09-09 : 13:19:11
You should probably ask this in a Java forum.

===
http://www.ElementalSQL.com/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-09 : 13:27:02
I don't have an example as I'm not a java programmer, however I know that our java applications use ServerName:PortNumber in the connection strings. We do not use IP address, and we always specify the listening port.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

spillo491
Starting Member

3 Posts

Posted - 2010-09-10 : 03:02:26
Problem is that sql server have windows authetication now !! Before with sql authentication mode I could connect to sql server.

sql server is on machine 192.168.3.6
Web server (clinet, my machine) is 192.168.3.10
Go to Top of Page

spillo491
Starting Member

3 Posts

Posted - 2010-09-10 : 03:04:13
Same error with this

dbUrl=jdbc:jtds:sqlserver://serverName:1099/db_test;instance=test
Connection con = DriverManager.getConnection( dbUrl, "", "" );

java.sql.SQLException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Go to Top of Page

RobertKaucher
Posting Yak Master

169 Posts

Posted - 2010-09-10 : 16:15:41
Try something like this:

jdbc:sqlserver://serverName:1099;databaseName=AdventureWorks;integratedSecurity=true;


See this article:
http://msdn.microsoft.com/en-us/library/ms378428(SQL.90).aspx

I still think you would get better results posting this to a Java forum.

===
http://www.ElementalSQL.com/
Go to Top of Page
   

- Advertisement -