views:

58

answers:

1

This might be a basic question, but I tried googling it and couldn't find an answer.

I need to make a list of all the SQL Servers on a network. This is very easy to do using the .NET framework (System.Data.Sql.SqlDataSourceEnumerator), but is there also a relatively simple way to do this in java as well? While I was doing my research, I came across the possibility of listening in at different ports, but that seemed un-user friendly. Any ideas?

Thank you all so much.

+1  A: 

You can use

osql -L

and parse output.

Sergey Mirvoda
I'm a newbie in sql. Can you give me some more information or a place to get more information?
chama
osql.exe is a command line tool. just search it on your hdd and execute with -L switch
Sergey Mirvoda
Here is the how to: http://www.databasejournal.com/features/mssql/article.php/3397981/Scanning-the-network-for-SQL-Server.htm I don't think you can redistribute osql.exe however.
Nissan Fan
SQL Servers have to make themselves available for browsing by running the SQL Server Browser Service so it's not a lock that you will find them.http://msdn.microsoft.com/en-us/library/ms181087.aspxIn addition, if a server is hidden by running in Shared Memory mode you won't be able to connect to it remotely.So your real question may be: how do I query the SQL Server Browser Service from Java?
Nissan Fan
so now that I know what my question is, how do I use sql server browser from java?
chama