CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: DBI:
perl jdbc


New User

Dec 27, 2008, 2:48 PM

Post #1 of 4 (6344 views)
perl jdbc Can't Post

I am using jdbc to connect perl to oracle using
source("usr/bin/perl ...... ")
for my web mining project.

when I execute it using


it enters values in the database but when I try to run my interface on browser it does not do anything.

Veteran / Moderator

Dec 28, 2008, 9:06 AM

Post #2 of 4 (6332 views)
Re: [pappusingh] perl jdbc [In reply to] Can't Post

When a perl script runs correctly from the command line but not when called as a cgi script, the most common reason is incorrect permission settings.

Have you looked at the web server error log? It should give you some clues.

Can you post the script for us to review?

New User

Dec 29, 2008, 1:23 AM

Post #3 of 4 (6323 views)
Re: [FishMonger] perl jdbc [In reply to] Can't Post

hi.. I am trying to execute this in perl

so when I click a link on my site it calls the cgi script and collects environment variables. Then I enter some information in the database.

I don't think its because of permissions because I have another script which uses another java file to insert data in database!! and that works.

this part of code calls the java program

system( "/usr/bin/java log '$DAY' '$TIME' '$FROM_URL' '$QUERY' '$REMOTE_IP' '$SERVER_PROTOCOL' '$GATEWAY_INTERFACE'");

which enters the values in the database as follows

String query = "insert into log( REQUEST_ID, DAY, TIME, FROM_URL, TO_URL, REMOTE_IP, SERVER_PROTOCOL, GATEWAY_INTERFACE) values (log_seq.nextval, '"+args[0]+"','"+args[1]+"', '"+args[2]+"', '"+args[3]+"', '"+args[4]+"', '"+args[5]+"','"+args[6]+"')";

REQUEST_ID is the primary key and auto increment.
all other fields are of type varchar. none of them except primary key is NOT NULL.
and to be specific for first couple of times when I call the cgi script some fields for example $FROM_URL will be passing NULL.
Does that creating a problem ?

In Reply To

Veteran / Moderator

Dec 29, 2008, 7:58 AM

Post #4 of 4 (6317 views)
Re: [pappusingh] perl jdbc [In reply to] Can't Post

Passing NULL values are fine as long as the db field allows it, but are sure that's what you're doing?

Could you be passing undef instead of NULL? They are not the same.
As a debugging test, you could print the string in the system call to verify it what you expect.

print "/usr/bin/java log '$DAY' '$TIME' '$FROM_URL' '$QUERY' '$REMOTE_IP' '$SERVER_PROTOCOL' '$GATEWAY_INTERFACE'";

There are several things you could do to fix this problem. The first and best starting point would be to use Perl's DBI and DBD::Oracle modules to interface with your Oracle db instead of doing the system call to a java program.

The next step would be to make sure that each of the vars are defined. The ones that are currently undef should be defined with an empty string or with 'NULL'. There are a couple ways to do that, here's one:

$FROM_URL = 'NULL' unless defined $FROM_URL;


$FROM_URL = '' unless defined $FROM_URL;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives