Reputation: 23
I'm trying to connect to a SQL Server DB with JDBC in java. This is my connection String:
"jdbc:sqlserver://XYZ\\SQLEXPRESS,3000;user=xxxxxx;password=xxxxx;databaseName=dbname;"
The server name is XYZ\SQLEXPRESS,3000. I escaped the \ character but im still getting the following error
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host XYZ, named instance SQLEXPRESS,3000 failed.
Upvotes: 2
Views: 1766
Reputation: 59950
The URL should look like this :
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
In your case :
"jdbc:sqlserver://XYZ\\SQLEXPRESS:3000;user=xxxxxx;password=xxxxx;databaseName=dbname;"
//-------------------------------^
Upvotes: 2
Reputation: 2505
Honestly, if it were me, I would make a new instance, sans commas. This seems like it will be a nightmare for you going forward.
edit: Apparently we're looking for a port number, not a comma in a SQL instance...
Upvotes: 0