This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connecting to DB2 with no database name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting to DB2 with no database name" Watch "Connecting to DB2 with no database name" New topic
Author

Connecting to DB2 with no database name

premesh purayil
Greenhorn

Joined: Nov 23, 2004
Posts: 17
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Nov 23, 2004
Posts: 17
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

Joined: Nov 23, 2004
Posts: 17
oh and im using the net driver.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Nov 23, 2004
Posts: 17
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

Noooooooooooooooooo.

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

Maybe I'll test it out.

Regards,

-Cameron
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Consider Paul's rocket mass heater.
 
subject: Connecting to DB2 with no database name
 
Similar Threads
WebSphere DB2 Connection Pool Setup
Strange problem with WAS and Sybase
DB/Connect
how do i connect java to my oracle server i,m just beginning on jdbc
Accessing Remote Databases