This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It doesn't matter how many instances of SQL Server you have installed on one machine, they all listen on port 1433 by default. It is the instance name that tells SQL server which instance you want not the port number. NB: I think the SQL Server docs suggest installing 2000 and 2005 on the same machine is unsupported - I can't remember exactly, but worth a check to make sure you aren't doing something that could cause you problems. If you need both on one machine, you can use an instance of 2005 in backwards compatability mode which limits it to 2000 behaviour.
SQL Server 2005 has the major version 9, SQL Server 2000 has the major version 8. So if you use DatabaseMetaData.getMajorVersion() you will be able to find out.
i want to know how can i connect to 2005 server.
Which JDBC driver are you using? If its the MS driver you need to define the instance name as part of the server name (see the documentation). If its jTDS you need to pass a property called "instance".