Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I check whether a DB2 database exists?

796 views
Skip to first unread message

wingso...@yahoo.com

unread,
Aug 18, 2006, 10:59:03 PM8/18/06
to
Hello,

Is there a way to check whether a DB2 database exists on server? For example, I created a DB2 database 'MyDatabase' which is empty, and I would like to verify that it exists from client side.

I thought of setting up a connection in which I set the database=MyDatabase in connection string. However it does not solve the problem as when it fails it might also be User/Password wrong. There must be a system level statement (to compare, such as master.dbo.sysdatabase statement in SQL server) to verify that the database exists.

Please help,

Thanks,

John

Larry Menard

unread,
Aug 18, 2006, 11:50:58 PM8/18/06
to
You could query the system catalogs, but that will only tell you that
there are pointers to the database in the catalogs, it does not guarantee
that the database actually physically exists.

As you said, you could just try to connect to it, but then you need to
know the exact reason for failures. This information is usually returned to
the client in a structure called the SQLCA, and DB2 provides APIs to help
process the info in that structure.

However, all of this might depend on a number of things, including:

- the platform(s) involved
- the version(s) of DB2 involved
- the API (application language) used.

Since there are no DB2 products in beta right now, this group might not
be monitored very closely. I'd suggest you post this question (with the
additional info I mentioned) in the "ibm.software.db2.udb" group (not
".beta") on this server... you're more likely to get better help there.

--
--------------------
Larry Menard
"Defender of Geese and of All Things Natural"


<wingso...@yahoo.com> wrote in message
news:526373976.1155956374...@ltsgwas010.sby.ibm.com...

sabrina...@gmail.com

unread,
Sep 19, 2013, 4:50:57 AM9/19/13
to
Did you get the answer to your question? I have the same issue and would be interested in sharing the solution.

Note that this code works fine for MySQL but not DB2:
http://www.roseindia.net/answers/viewqa/JDBC/13110-How-to-check-whether-database-exists.html

Thanks,
Sabrina
0 new messages