I am trying to connect to a SQL Server database using JDBC, the database I am trying to connect to contains a space, and unfortunately I have no control over the name, so I cannot change it.
The code I use is:
String jdbcString = "jdbc:sqlserver://" + hostname + ":" + port + ";databaseName=Database Name"; try { connection = DriverManager.getConnection(jdbcString, username, password); }
I also tried following the instructions at this link: http://msdn.microsoft.com/en-us/library/ms378428%28SQL.90%29.aspx by placing space inside curly braces:
String jdbcString = "jdbc:sqlserver://" + hostname + ":" + port + ";databaseName=Database{ }Name";
but it doesnβt work either.
The error message I gee:
ERROR: Couldn't connect to the database: The connection string contains a badly formed name or value.
I am using the latest Microsoft JDBC driver.
source share