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 > Problem when connecting to Database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-07-08, 08:52
lokesh_gla lokesh_gla is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Problem when connecting to Database

Hi All,

I am facing problem when trying to connect to database.

#!/bin/bash

db2 "connect to QA_DB user db2admin using admin!@#"
ls
db2 "select count(*) from ORDER"
db2 "connect reset"


I am getting error:
-bash: !@#": event not found

Can anyone please solve my problem.
Reply With Quote
  #2 (permalink)  
Old 04-07-08, 09:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You have to escape the special characters or your shell (bash) will try to interpret them. One approach is to put single-quotes around the CONNECT command.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 04-07-08, 09:12
lokesh_gla lokesh_gla is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Hi Stolze,

Thanks for reply I tried by putting single-quotes but getting error

[db2usr1@ps0259 ~]$ db2 'connect to QA_DB user db2admin using admin!@#'
SQL0104N An unexpected token "!" was found following "ADMIN". Expected
tokens may include: "NEW". SQLSTATE=42601


Can you please suggest something else how to escape these special characters.
Reply With Quote
  #4 (permalink)  
Old 04-07-08, 09:23
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Try a '\' as escape character.

Other than that, don't use an exclamation mark in passwords...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-07-08, 09:31
lokesh_gla lokesh_gla is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
I also tried with \ but

[db2usr1@ps0259 ~]$ db2 'connect to QA_DB user db2admin using admin\!@#'
SQL0104N An unexpected token "!" was found following "<identifier>".
Expected tokens may include: "NEW". SQLSTATE=42601



I have to use ! sign in password because thats the requirement.

if u can suggest somethine else then it will be great for me.
Reply With Quote
  #6 (permalink)  
Old 04-07-08, 10:00
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Actually, I think if you use special characters in the password you also need to enclose the password itself in quotes, so it should end up like this:
Code:
db2 'connect to QA_DB user db2admin using "admin!@#"'
Reply With Quote
  #7 (permalink)  
Old 04-07-08, 10:15
lokesh_gla lokesh_gla is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
yes it worked.

Thanx a lot
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