| 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: 4967
|
|
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
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
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 : jdbc racle: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: 4967
|
|
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: 4967
|
|
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: 26496
|
|
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
|
 |
 |
|
|
subject: Connecting to DB2 with no database name
|
|
|