Issue in connecting to database named "test;abc" (semi colon).
Ramesh Janardanan
Greenhorn
Joined: Mar 05, 2008
Posts: 2
posted
0
I am trying to connect to a database named "test;abc" in my code but it fails because of the semi colon present in the DB name. How do I address this issue? any help
According to my reading of the SQL specification, semicolons are not valid characters in SQL identifiers. So you should avoid them, since much SQL-handling software may choke on them.
I too agree with you, that database name with semi-colon should be avoided.
Since creating a new database in MS SQL with semi-colon ("aa;bb;cc") is accepted, is there any posibility to fix this issue through our getConnection() method?
Given this is SQL Server you could try enclosing the offending database name in square brackets. This is what SQL Server uses to escape keywords and the like, so it may work.