gds03
gds03

Reputation: 1379

JDBC Jtds can't establish a connection

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.

Upvotes: 4

Views: 4231

Answers (1)

gds03
gds03

Reputation: 1379

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]

Upvotes: 7

Related Questions