Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Location
    Germany
    Posts
    19

    Unanswered: 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!

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  3. #3
    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

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    Re: DB2 get db cfg ... and Java

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

    Andy

    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).

  5. #5
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    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.

  6. #6
    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.


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

    Andy
    Kezban

  7. #7
    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?


    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).

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    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

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •