File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to DB2 with no database name

 
premesh purayil
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have a utility that i use ( written in java) to setup my databases used by my application. It works like a charm on Oracle , Derby, MySQL and SQLServer. Basically it connects to the db drobs the two databases if they exist and re creates them. Problem is that i cant connect to DB2 without specifying a DB name. Ideally I do not want to have the user go into the DB2 control panel and create a dummy db just so my utility can have the db to connect to.
what should the URL be to connect to DB2 as i discribed above?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a db2 dude, so I've never even heard about connecting to a database without specifying a database name. You've just blown my mind sky high.

Any chance you could enlighten me, and show me what the database URL was that you provided when you connected to those other fly-by-night databases you mentioned?

By the way, are you using the IBM db2 app or net driver?

Regards,

-Cameron McKenzie
 
premesh purayil
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL well atleast im providing some entertainment huh? The URLS i use for the other DBS are as follows:

Oracle : jdbcracle:thin:@localhost:1521
SQLServer : jdbc:sqlserver://localhost

Basically i want the ability to programtically create a database and users... however that is possible
 
premesh purayil
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh and im using the net driver.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dude. I've never seen such Haitian Vodoo Magic in my life. How does your code know which database to connect to?

I'm going to be of absolutely no help, I'm afraid. I was going to my grave thinking you had to supply the database name in the URL.

You have rocked my world.

-Cameron
 
premesh purayil
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha. so basically your are telling me there is no way to programtically create a database in DB2?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noooooooooooooooooo.

Just saying I haven't done it in my limited experience.

Maybe I'll test it out.

Regards,

-Cameron
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33667
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by premesh purayil:
haha. so basically your are telling me there is no way to programtically create a database in DB2?

Not through JDBC. You could use Runtime.exec to call an operating system shell script to do the work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic