in reply to perl remote oracle database connection

When trying new things in perl, I typically start with the simplest possible code and work up from there. In this case, I wouldn't put all of this in a CGI environment before troubleshooting your database code. In the case of your error, it is NOT from your database call, but is a CGI error that arises from not supplying appropriate header information to the browser. Work on the two pieces separately until you have a working "hello world" CGI script and a simple connection and pull data from the database. Once you have the two working, then you can combine them.

Just my opinion, though.

Sean

  • Comment on Re: perl remote oracle database connection

Replies are listed 'Best First'.
Re^2: perl remote oracle database connection
by cynosure (Initiate) on May 25, 2006 at 20:25 UTC
    I wrote simple perl scripts and they run fine. In my script I get the "premature end of script" error the moment I add this line
    my $dbh = DBI->connect('dbi:Oracle:host=host.domain.tld;sid=SID;port=1 +521', 'USER', 'PASS', { RaiseError => 1, AutoCommit => 0 });
    Is this some issue with the DBD::Oracle????
    This is what I get: -
    Server error! The server encountered an internal error and was unable to complete your request. Error message: Premature end of script headers: connect-test.pl
    If you think this is a server error, please contact the webmaster. Error 500

    I really don't know whats the issue. I tried setting oracle environment variables in the script but no help.
    Please help!!!!
      Are the simple perl scripts CGI or Oracle connection scripts?

      The first thing you should do is run your oracle connect on the command line until you know it is working right (without the cgi)... That way atleast you will get STDERR.

      Question two: do you have the Oracle client installed?
      I seem to remember that Oracle-DBD by itself is no good. You need to also install the Oracle client and get it configured to connect to a remote Oracle Database through such application as SQLPLUS. Then install Oracle-DBD.
      (Its been awhile since I have done anything with this so things might have changed... I just remember Oracle being the complete antithesis of a simple MySQL connection string.)


      You should also check your cgi configuration to make sure you are sending appropriate headers etc from Apache. This could be done by making a simple hello world test using the <h1>Hello World</h1> syntax.


      When both pieces prove to work independently of each other, then you can combine them...
      Tobin

      UPDATE: Oracle Client Lite is also available, but won't include some of the more useful Oracle products like (SQL*Plus). Unless you are very good at configuring TNS listeners etc., I would stick with the whole client package.
      If you truly want to debug the script as CGI, you will need to access your server error log. That is where the actual errors generated by your script will be located. However, I will reiterate my previous sentiment and that of Tobin that you need to make sure that the CGI "Hello world" script works and that you have a script that successfully connects to and can query the database. Once you have both, then you can begin to combine them.

      Sean