aspose file tools*
The moose likes JDBC and the fly likes List all available sql server running on my lan/network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "List all available sql server running on my lan/network" Watch "List all available sql server running on my lan/network" New topic
Author

List all available sql server running on my lan/network

Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
Is there any one capable of listing all the running sql servers on the lan.

i am on an intranet on each computer (50 out of 70) computers have sql servers installed, now i want to list all the available sql servers in core java. i just want the names of all ther servers. so that i can connect to them as i know user name and pass words of each of them.


Rituraj Jain
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There is no API to do this in Java. There are API in VB and C#, so you will need to first write your program in one of those languages then call this program via the ProcessBuilder.

The libraries MS supply to do this sort of thing are:
  • Microsoft.SqlServer.Management.Smo
  • Microsoft.SqlServer.ConnectionInfo


  • Have a look in MSDN for more info. Be aware that there is a difference between those visible over the LAN and those accessable over the LAN; there may be more out there than your program can see. SQL Server has a broadcast service that announces the existance of an instance (which is what makes stuff appear in the drop down from the Management Studio when you create a connection) which is not required to make a default instance accept connections from remote clients.

    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Rituraj Jain
    Ranch Hand

    Joined: Nov 28, 2008
    Posts: 37
    thnx for reply. but i was wondering if i can write a program in java.. anyways thnx for reply
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    No. You could write a Java program that tried to discover SQL Server instances by connecting to every node in your LAN on port 1433 and examining the response. However, you would still need to discover evey node in the LAN and you would not be able to discover the SQL Server instances that are not configured to allow TCP/IP connections (which is the default from version 2005 onwards) unless the SQL Server Browser service is running on that node. Since the browser service is optional, and is a likely candidate to be disabled for security reasons you can't rely on that either.

    Writing this in VB or C# is easy however. Calling a VB or C# program from Java via the ProcessBuilder is also easy. I'd use that route if I were you.
    Rituraj Jain
    Ranch Hand

    Joined: Nov 28, 2008
    Posts: 37
    thanks for suggestion. i think using of ProcessBuilder is a better way as you said, so i am going to use that way.

    Thanks
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: List all available sql server running on my lan/network