Error connecting JDBC to local sql Server

Asked

Viewed 2,058 times

-3

I try to connect java with Sql Server from my local machine but I get this error

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost,
port 1434 has failed.
Error: Connection refused: connect. Please verify the connection properties and check that
a SQL Server instance is running on the host and accepting TCP/IP connections at the port,
and that no firewall is blocking TCP connections to the port.

My Connection Line.

Connection con = DriverManager.getConnection(
           "jdbc:sqlserver://localhost:1434;databaseName=ASSERTIVA_TESTE",
           "marcelo",
           "0869");` 
  • 4

    Marcelo, you are absolutely sure that SQL Server is on the port 1434? The standard is 1433. The error in question has nothing to do with Java or the driver, but the server has not been found.

  • Truth is door 1433 but I keep getting the same error.

  • The problem is then in the installation or configuration of your database. Have you even installed SQL Server on your local machine? The service is initialized?

  • to work with localhost sql-server needs to have the namePipe protocol enabled in the settings, already checked there?

  • Look at this in Sql Configuration manager and Named Pipes this active, TCP/IP is also enabled

  • Without specifying the DB to connect? jdbc:sqlserver://localhost;user=MyUserName;password=*****;

Show 1 more comment

2 answers

0

Just use the JTDS. The Microsoft Driver is cursed and will make you spend a lot of time trying to set up until you give up and get frustrated to then decide to use the JTDS.

  • 1

    Could you elaborate on why your answer ? In order to add;

0

Marcelo,

Try the following one: Add port 1433 to your Windows Firewall rules to allow the exception. Within Sql Manager Studio Enable "Allow remote Connections To This Server" option No Configuration Manager Enter the settings with Configuration Manager and Enter the TCP/IP protocol properties, in IP Addresses in the Ipall menu enter the port in the TCP Port field. Restart the SQL Server service from your instance and try again.

 Não sei se ajudara mais fiz desta forma e funcionou corretamente.

 O tutorial que ajudou muito foi: http://sqlfromhell.wordpress.com/2010/04/18/habilitando-o-acesso-remoto-no-sql-server-2008/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.