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 > Create Database problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-06-06, 05:44
stackoverflow stackoverflow is offline
Registered User
 
Join Date: Sep 2006
Location: Russian Federation, Moscow
Posts: 2
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 ?
Reply With Quote
  #2 (permalink)  
Old 09-06-06, 06:10
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
  #3 (permalink)  
Old 09-06-06, 07:23
singhipst singhipst is offline
Registered User
 
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 !!**
Reply With Quote
  #4 (permalink)  
Old 09-06-06, 07:30
stackoverflow stackoverflow is offline
Registered User
 
Join Date: Sep 2006
Location: Russian Federation, Moscow
Posts: 2
Big Thanks
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