JDBC Jtds can't establish a connection

£可爱£侵袭症+ 提交于 2019-12-11 00:18:32

问题


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

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();

    }

And I receive this error:

Server ASUS has no instance named MSSQLSERVER1.

It makes sense?

I have the MSSQLSERVER1 service running.


回答1:


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]



来源:https://stackoverflow.com/questions/3897075/jdbc-jtds-cant-establish-a-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!