aspose file tools
The moose likes JDBC and the fly likes Issue in connecting to database named Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Issue in connecting to database named "test;abc" (semi colon)." Watch "Issue in connecting to database named "test;abc" (semi colon)." New topic
Author

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

Ramesh Janardanan
Greenhorn

Joined: Mar 05, 2008
Posts: 2
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
Marshal

Joined: Mar 22, 2005
Posts: 35222
    
    7
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.


Android appsImageJ pluginsJava web charts
Ramesh Janardanan
Greenhorn

Joined: Mar 05, 2008
Posts: 2
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue in connecting to database named "test;abc" (semi colon).
 
Similar Threads
getting zelo value of varibales.
Why Two Forms Post Differently
Generics <?>
Performance issue for Storing data in database
decode an inputstream