If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 get db cfg ... and Java

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-03, 02:07
mrkarlsruhe mrkarlsruhe is offline
Registered User
 
Join Date: Sep 2003
Location: Germany
Posts: 19
DB2 get db cfg ... and Java

Is it possible to query the parameters shown with the "db2 get db cfg" command with Java?? Perhaps I can use JDBC ??
Or is there an other possibility to get information about the codeset and the territory of a database with java?

Thanks for answers!
Reply With Quote
  #2 (permalink)  
Old 12-03-03, 08:45
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
First of all, yes it is possible--but it is not straightforward.
What you want to run is a DB2 command and will not work using jdbc. So the question is how do you execute a DB2 command in java? First you need to run the java app in a DB2 Command Window. Then you issue the DB2 commands to the parent process (DB2 Command Window) and read back in the results. Goto DB2 sample code web site:

http://www.developer.ibm.com/tech/sampdb2.html

and look for the java sample to run RUNSTATS. That will help guide you on writing java apps that can execute DB2 commands.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 12-03-03, 08:56
KezbanB KezbanB is offline
Registered User
 
Join Date: Jun 2003
Location: İstanbul
Posts: 19
Re: DB2 get db cfg ... and Java

Hi,

Probably you already know this method but I can tell how I learn database parameters using Java.
I use;
Process p = Runtime.getRuntime().exec("db2cmd /c /w /i db2 get db cfg for <dbname>");
and get the result with BufferedReader.

I would be happy to learn a better method if it's possible (with JDBC or something else).
__________________
Kezban
Reply With Quote
  #4 (permalink)  
Old 12-03-03, 09:07
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Re: DB2 get db cfg ... and Java

That is basically what I outlined above. There is no way to do it in JDBC.

Andy

Quote:
Originally posted by KezbanB
Hi,

Probably you already know this method but I can tell how I learn database parameters using Java.
I use;
Process p = Runtime.getRuntime().exec("db2cmd /c /w /i db2 get db cfg for <dbname>");
and get the result with BufferedReader.

I would be happy to learn a better method if it's possible (with JDBC or something else).
Reply With Quote
  #5 (permalink)  
Old 12-03-03, 09:12
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: DB2 get db cfg ... and Java

A table function MAY be an option ...

ie create a tablefunction to get the db cfg as a table and over jdbc you can use the tablefunction just as you would a DB2 UDF ..

Good luck

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #6 (permalink)  
Old 12-03-03, 09:32
KezbanB KezbanB is offline
Registered User
 
Join Date: Jun 2003
Location: İstanbul
Posts: 19
Re: DB2 get db cfg ... and Java

I haven't seen your answer while I was writing my post. Thanks for the info on JDBC.


Quote:
Originally posted by ARWinner
That is basically what I outlined above. There is no way to do it in JDBC.

Andy
__________________
Kezban
Reply With Quote
  #7 (permalink)  
Old 12-09-03, 09:04
mrkarlsruhe mrkarlsruhe is offline
Registered User
 
Join Date: Sep 2003
Location: Germany
Posts: 19
Re: DB2 get db cfg ... and Java

Zahnk you for your advice! It works!
But what about using a remote database? Before i can get such informations i must connect to the db from e.g. the command window an then run the java class!
But i don't like that methode. Is there an other possibility?? JDBC Connection?


Quote:
Originally posted by KezbanB
Hi,

Probably you already know this method but I can tell how I learn database parameters using Java.
I use;
Process p = Runtime.getRuntime().exec("db2cmd /c /w /i db2 get db cfg for <dbname>");
and get the result with BufferedReader.

I would be happy to learn a better method if it's possible (with JDBC or something else).
Reply With Quote
  #8 (permalink)  
Old 12-09-03, 09:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Re: DB2 get db cfg ... and Java

The JDBC connection will not work the way you would hope.
But you can have the java program issue the CONNECT command just like all of the other commands.

HTH

Andy

Quote:
Originally posted by mrkarlsruhe
Zahnk you for your advice! It works!
But what about using a remote database? Before i can get such informations i must connect to the db from e.g. the command window an then run the java class!
But i don't like that methode. Is there an other possibility?? JDBC Connection?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On