Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Location
    Russian Federation, Moscow
    Posts
    2

    Unanswered: Create Database problem

    Hello,
    I am new to DB2.

    I am using DB2 9.1 on windows

    The requirement is I have to create a batch file.

    It creates a database and creates the tables in it.

    So that the user of this batch file can run this batch file on the server machine where
    DB2 is running, and then they should be able to use database name/user name/password
    in java to connect to this newly created instance from their client machines.

    The 2 scripts for this (create db and create tables) are working fine when
    I use 'db2cmd db2 ... ', but when I put this into a batch file I am having problems.

    I created the following batch file:
    createDatabase.bat
    db2cmd db2 -f createDatabase.sql

    This starts another shell, and creates the tables, but leaves the shell open when it is done.
    Is there any way to get the shell to close by itself ?
    I have tried adding QUIT and EXIT but the shell is still open after the command execution.

    So how can I close the db2 shell after it is done executing the commands ?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    http://www.db2click.com/scribble.htm

    Look under the head 'db2cmd Options'

    HTH
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jul 2006
    Location
    Bangalore
    Posts
    57
    Create a test file
    eg c:\test.txt
    Now write all db2 commands here with terminator descriptor ! or ; whatever you want.
    Now create one batch file
    eg sub.bat
    now write
    DB2 -TD! -VF C:\test.txt -Z C:\out.txt
    Now finaly create on more batch file what you want
    eg createDatabase.bat
    now write in this batch file
    DB2CW @C:\SUB.BAT

    i hope it will helpfull for you
    Ritesh Kumar Singh
    IBM Certified DB2 DBA for LUW
    **Knowledge Is Theft If Not Shared !!**

  4. #4
    Join Date
    Sep 2006
    Location
    Russian Federation, Moscow
    Posts
    2
    Big Thanks

Posting Permissions

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