Search code examples
javasqlsql-serversqlbrowser

How do I query SQL Browser Service from Java?


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.

I've been told to use SQL Browser Service, but a) I couldn't find any information on how to call that from java, and b) does this service get automatically downloaded when you download SQL Server? Can I assume that every computer on the network I'm searching has access to this browser service? And if not, does that make a difference to my code?

Thank you all so much.


Solution

  • You can use SQLBrowseConnect function from ODBC API.