ive got a method that connects to sql server using JTDS

String url = "jdbc:jtds:sqlserver://192.168.12.123;instance=server-e61t7rvb;DatabaseName=test";
     String driver = "net.sourceforge.jtds.jdbc.Driver";
    String userName = "sa";
    String password = "hello";

                Class.forName(driver);
        conn = DriverManager.getConnection(url, userName, password);
        System.out.println("Connected to the database!!! Getting table list...");
        DatabaseMetaData dbm = conn.getMetaData();
        rs = dbm.getTables(null, null, "%", new String[] { "TABLE" });
        while (rs.next())  System.out.println(rs.getString("TABLE_NAME"));

using this i can connect fine to SQL 2008 but when i change it to a SQL 2000 server i get "server has no instance named " for the instance name i am running

select @@servername 

note that i can use the instance name to log into the server from my computer using sql management studio.

any help much appreciated

有帮助吗?

解决方案

removed the instance parameter and it worked fine

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top