• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connecting to DB2 with no database name

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh and im using the net driver.
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic