JDBC Jtds无法建立连接 [英] JDBC Jtds can't establish a connection

查看:326
本文介绍了JDBC Jtds无法建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要访问的SQL数据库比放置在ASUS\MSSQLSERVER1中的SQL数据库和数据库名称"Test"的访问权限都可以用密码teste来访问用户teste

I want to make a access to my sql database than is placed in ASUS\MSSQLSERVER1 and database names "Test" with access to user teste with password teste

在Java代码中,我对此进行了编码:

in java code I coded this:

@Test
    public void TesteTemp() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException
    {
        Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
        String connString = "jdbc:jtds:sqlserver://ASUS/Test;instance=MSSQLSERVER1;user=teste;password=teste;";

        Connection conn = null;
        try{
            conn = DriverManager.getConnection(connString);
        }catch(SQLException ex){
            ex.printStackTrace();
        }
        conn.close();

    }

我收到此错误:

服务器ASUS没有名为MSSQLSERVER1的实例.

Server ASUS has no instance named MSSQLSERVER1.

有道理吗?

我正在运行MSSQLSERVER1服务.

I have the MSSQLSERVER1 service running.

推荐答案

我解决了问题..代码可以,问题是tcp/ip协议和命名管道被禁用,我只是激活了它们,现在运行好的.. SQL配置管理器> SQL服务器网络配置> [Server_Name]的协议

i resolved the problem.. the code is ok, the problem was than protocols for tcp/ip and named pipes were disabled, i just activated them, now runs ok.. Sql Configuration Manager > Sql Server Network Configuration > Protocols for [Server_Name]

这篇关于JDBC Jtds无法建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆