Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue in connecting to database named "test;abc" (semi colon).

 
Ramesh Janardanan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

example:
String url = "jdbc:msql://www.myserver.com:1114/test;abc";
Connection conn = DriverManager.getConnection(url,"user","password");

Thanks
-Ramesh
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

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.
 
Ramesh Janardanan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply

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?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic