Could not connect to the database Network error IOException: Connection refused: connect

Allen

I am running a SQL Server Express 10.50.4000.0 on my machine. I have enabled on the TCP/IP and made sure the port is set to 1433. I have added an exception in my firewall for 1433. The server service is running. I have tried localhost and the computer name and both give the same error. When i try localhost\SQLEXPRESS or [USER-PC]\SQLEXPRESS I received an error saying it could not find the database.

String driverName = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driverName);

String serverName = "localhost";
String instanceName = "ALLEN-PC\\SQLEXPRESS";
String serverPort = "1433";
String database  = serverName +":" + serverPort+"/"+instanceName;
String url = "jdbc:jtds:sqlserver://" + database;
String username = "sa";
String password = "password";

connection = DriverManager.getConnection(url, username, password);

I receive the error:

Could not connect to the database Network error IOException: Connection refused: connect

with no additional context to investigate.

Adam Haines

Your connection string needs to be in this format. Found here: http://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx

jdbc:jtds:sqlserver://<yourDBServerIPAddress>\SQLEXPRESS:1433;databaseName=AdventureWorks;user=sa;password=*****;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

"psql: could not connect to server: Connection refused" Error when connecting to remote database

docker build error: psql: could not connect to server: Connection refused

RabbitMq error -Connection refused: connect

Could not connect to Redis at 127.0.0.1:6379: Connection refused

PG::ConnectionBad - could not connect to server: Connection refused

PG::ConnectionBad: could not connect to server: Connection refused

pg_dump: [archiver (db)] connection to database "development" failed: could not connect to server: Connection refused

Odoo container : Database connection failure: could not connect to server: Connection refused (linking odoo with localhost postgres)

Odoo 14 in Docker: Database connection failure: could not connect to server: Connection refused

Failed to get bus connection: Could not connect: Connection refused

System error 111 (connection refused) , Failed to connect

Connection refused: connect Error in Java + Hibernate

Endorser client failed to connect : connection refused Error

Error 'Could not connect to TraCI server at localhost: 40335 [Errno 111] Connection refused'

"psycopg2.OperationalError: could not connect to server: Connection refused" error when bootstrapping

failed to initialize database, got error failed to connect to `host=db user= database=`: dial error (dial tcp xxxx: connect: connection refused)

ftp: connect :Connection refused

Could not connect to Redis at 127.0.0.1:6379: Connection refused in docker

WSL - GEDIT Unable to init server: Could not connect: Connection refused

Heroku: PG::ConnectionBad: could not connect to server: Connection refused

Could not connect to Redis at 127.0.0.1:6379: Connection refused with homebrew

rake aborted! PG::ConnectionBad: could not connect to server: Connection refused

Ubuntu 18.04 abiword - Unable to init server: Could not connect: Connection refused

django.db.utils.OperationalError: could not connect to server: Connection refused

IOException java.net.ConnectException: failed to connect to /127.0.0.1(port 5000):connect failed:ECONNREFUSED(Connection Refused)

Getting error: "Error constructing proxy for org.gnome... Could not connect: Connection refused" when running gnome-terminal

Network Error: No connection could be made because the target machine actively refused it

Docker- django throws error while connecting to postgres: psycopg2.OperationalError: could not connect to server: Connection refused

sudo apt-get update : Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)