Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2008
    Posts
    4

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

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

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

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

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

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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!@#"'
    ---
    "It does not work" is not a valid problem statement.

  7. #7
    Join Date
    Apr 2008
    Posts
    4
    yes it worked.

    Thanx a lot

Posting Permissions

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