I have a connection string from ASP.Net which I have to use in my Java Application, however, I can't seem to figure out why it's not working.
This is the error I'm getting: Cannot establish a connection to jdbc:sqlserver://localhost:1433;databaseName=MyDatabase;" using com.microsoft.sqlserver.jdbc.SQLServerDriver (The connection string contains a badly formed name or value.)
I'm using Microsoft JDBC 2005 driver (somehow it selected 2005 when I created a new driver for my persistence unit using sqljdbc_7.2.1.0). I'm using SQL Server Express 2017.
I'm trying to figure out which part of the string goes in which field:
My string is "Server=.\sqlexpress;Database=MyDatabase;Trusted_Connection=True;MultipleActiveResultSets=true"
Those are the fields I'm trying to figure out.
host: localhost ( Also tried .\SQLEXPRESS, doesn't work either )
port: 1433
Database: MyDatabase
Instance name: ???
Username: ???
Password: ???
I also checked my TCP ports on SQL configuration, I noticed TCP was turned off and there was no port, I changed this to 1433.
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
. – Mark Rotteveel