FAQ
Our web server is running Apache 2.0.48 with mod_perl 1.99_12 on a Sun
machine running Solaris 9. We are running perl 5.8.1, DBI 1.39 and
DBD-Oracle 1.16. We are trying to connect from our web server to an
Oracle database that is on a different machine. The script that we
wrote to do this runs perfectly well when we run it from the command
line as a plain user. However, when we try running it from the web, we
cannot connect to the database.
When running from the web, the following environment variables are
printed properly:
TWO_TASK
ORACLE_SID
LIBPATH
LD_LIBRARY_PATH
ORACLE_HOME
SHLIB_PATH

I use the following code to connect to the database:
if ( ! ($dbh = DBI->connect("dbi:Oracle:", $dbuser, '', { PrintError =>
0, AutoCommit => 0 }))) {
print "Error: cannot connect to DB<br>\n";
exit(0);
}
$dbuser is defined as
$dbuser = 'userid/password';

After all the environment variables are printed out, I get the message
Error: cannot connect to DB

As I said at the start, the script works perfectly well from the
command line even when it is run from the same userid that the web runs
under.

Any suggestions to get this working from the web will be greatly
appreciated. Thanks in advance.




Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbalista@weizmann.ac.il
08-934-3036

Search Discussions

  • Reidy, Ron at May 25, 2005 at 2:22 pm
    Well, to start, you should **always** print the Oracle error message ($DBI->errstr). This will tell you more than we on this list could even hope to guess.

    Next, if it runs from the command line, then you most likely have a permissions issue with either the Perl script itself, or the Oracle.so library.

    -----------------
    Ron Reidy
    Lead DBA
    Array BioPharma, Inc.


    -----Original Message-----
    From: Malka Cymbalista
    Sent: Wednesday, May 25, 2005 5:47 AM
    To: dbi-users@perl.org
    Subject: problem with DBD::Oracle


    Our web server is running Apache 2.0.48 with mod_perl 1.99_12 on a Sun
    machine running Solaris 9. We are running perl 5.8.1, DBI 1.39 and
    DBD-Oracle 1.16. We are trying to connect from our web server to an
    Oracle database that is on a different machine. The script that we
    wrote to do this runs perfectly well when we run it from the command
    line as a plain user. However, when we try running it from the web, we
    cannot connect to the database.
    When running from the web, the following environment variables are
    printed properly:
    TWO_TASK
    ORACLE_SID
    LIBPATH
    LD_LIBRARY_PATH
    ORACLE_HOME
    SHLIB_PATH

    I use the following code to connect to the database:
    if ( ! ($dbh = DBI->connect("dbi:Oracle:", $dbuser, '', { PrintError =>
    0, AutoCommit => 0 }))) {
    print "Error: cannot connect to DB<br>\n";
    exit(0);
    }
    $dbuser is defined as
    $dbuser = 'userid/password';

    After all the environment variables are printed out, I get the message
    Error: cannot connect to DB

    As I said at the start, the script works perfectly well from the
    command line even when it is run from the same userid that the web runs
    under.

    Any suggestions to get this working from the web will be greatly
    appreciated. Thanks in advance.




    Malka Cymbalista
    Webmaster, Weizmann Institute of Science
    malki.cymbalista@weizmann.ac.il
    08-934-3036

    This electronic message transmission is a PRIVATE communication which contains
    information which may be confidential or privileged. The information is intended
    to be for the use of the individual or entity named above. If you are not the
    intended recipient, please be aware that any disclosure, copying, distribution
    or use of the contents of this information is prohibited. Please notify the
    sender of the delivery error by replying to this message, or notify us by
    telephone (877-633-2436, ext. 0), and then delete it from your system.
  • Michael A Chase at May 26, 2005 at 1:15 am

    On 05/25/2005 04:46 AM, Malka Cymbalista said:

    Our web server is running Apache 2.0.48 with mod_perl 1.99_12 on a Sun
    machine running Solaris 9. We are running perl 5.8.1, DBI 1.39 and
    DBD-Oracle 1.16. We are trying to connect from our web server to an
    Oracle database that is on a different machine. The script that we
    wrote to do this runs perfectly well when we run it from the command
    line as a plain user. However, when we try running it from the web, we
    cannot connect to the database.
    As I said at the start, the script works perfectly well from the
    command line even when it is run from the same userid that the web runs
    under.

    Any suggestions to get this working from the web will be greatly
    appreciated. Thanks in advance.
    After environment variables, I'd check the access rights to Oracle.so
    and the files in $ORACLE_HOME/lib.

    --
    Mac :})
    ** I usually forward private questions to the appropriate mail list. **
    Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
    Give a hobbit a fish and he eats fish for a day.
    Give a hobbit a ring and he eats fish for an age.
  • Malka Cymbalista at May 30, 2005 at 8:32 am
    Thanks to everyone who replied and suggested that I print out the Oracle
    error message. When I run the script from the web, I get the
    following:

    ERROR OCIEnvNlsCreate (check ORACLE_HOME and NLS settings etc.)
    Error: cannot connect to DB

    However, the script also prints out the environment variables and the
    following is printed:
    ORACLE_HOME : /usr/local/ora9i/9.2.0
    NLS_NUMERIC_CHARACTERS : .,
    NLS_DATE_FORMAT : DD-MON-RR
    NLS_SORT : binary
    NLS_LANG : American_America.UTF8

    I want to emphasize that when I run the script from the command line
    with the same user that runs apache, everything works properly so I
    don't think there is a problem with the permissions.
    Does anyone have any ideas.


    Malka Cymbalista
    Webmaster, Weizmann Institute of Science
    malki.cymbalista@weizmann.ac.il
    08-934-3036
    "Reidy, Ron" <Ron.Reidy@arraybiopharma.com> 25/05/2005 17:21 >>>
    Well, to start, you should **always** print the Oracle error message
    ($DBI->errstr). This will tell you more than we on this list could even
    hope to guess.

    Next, if it runs from the command line, then you most likely have a
    permissions issue with either the Perl script itself, or the Oracle.so
    library.

    -----------------
    Ron Reidy
    Lead DBA
    Array BioPharma, Inc.


    -----Original Message-----
    From: Malka Cymbalista
    Sent: Wednesday, May 25, 2005 5:47 AM
    To: dbi-users@perl.org
    Subject: problem with DBD::Oracle


    Our web server is running Apache 2.0.48 with mod_perl 1.99_12 on a
    Sun
    machine running Solaris 9. We are running perl 5.8.1, DBI 1.39 and
    DBD-Oracle 1.16. We are trying to connect from our web server to an
    Oracle database that is on a different machine. The script that we
    wrote to do this runs perfectly well when we run it from the command
    line as a plain user. However, when we try running it from the web,
    we
    cannot connect to the database.
    When running from the web, the following environment variables are
    printed properly:
    TWO_TASK
    ORACLE_SID
    LIBPATH
    LD_LIBRARY_PATH
    ORACLE_HOME
    SHLIB_PATH

    I use the following code to connect to the database:
    if ( ! ($dbh = DBI->connect("dbi:Oracle:", $dbuser, '', { PrintError
    =>
    0, AutoCommit => 0 }))) {
    print "Error: cannot connect to DB<br>\n";
    exit(0);
    }
    $dbuser is defined as
    $dbuser = 'userid/password';

    After all the environment variables are printed out, I get the message

    Error: cannot connect to DB

    As I said at the start, the script works perfectly well from the
    command line even when it is run from the same userid that the web
    runs
    under.

    Any suggestions to get this working from the web will be greatly
    appreciated. Thanks in advance.




    Malka Cymbalista
    Webmaster, Weizmann Institute of Science
    malki.cymbalista@weizmann.ac.il
    08-934-3036

    This electronic message transmission is a PRIVATE communication which
    contains
    information which may be confidential or privileged. The information is
    intended
    to be for the use of the individual or entity named above. If you are
    not the
    intended recipient, please be aware that any disclosure, copying,
    distribution
    or use of the contents of this information is prohibited. Please notify
    the
    sender of the delivery error by replying to this message, or notify us
    by
    telephone (877-633-2436, ext. 0), and then delete it from your system.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedMay 25, '05 at 11:47a
activeMay 30, '05 at 8:32a
posts4
users3
websitedbi.perl.org

People

Translate

site design / logo © 2022 Grokbase