Home: General Discussions: General Questions:
Perl web application can not connect new oracle database

New User

Jun 28, 2016, 9:14 PM

Views: 8717
Perl web application can not connect new oracle database

We have a Perl based internal web application. We have 2 servers, one for production and another for test. Both were pointing same database server which is declared in the common.pm files.
I have been assigned this project to use different database for test server. I am learning pearl from online and using text book.
I have made ready oracle based test database which is replicated the production one. I can connect database using SQL developer application.
I have edited to change the database name in the common.pm file where the database name was the production one. But it is not connecting to the database.
Could anyone please help me to resolve this issue? Thanks in advance.

Is there any information where I can check for oracle ODBC connection driver installed in the server?

(This post was edited by newtonbd on Jun 30, 2016, 8:08 PM)

Veteran / Moderator

Jul 1, 2016, 6:57 AM

Views: 8680
Re: [newtonbd] Perl web application can not connect new oracle database

Since you haven't shown any code or error messages, it's hard to say what's wrong.

Is your script using the DBI module, like it should be doing, to connect to the database? If you're using DBI, then the driver module is DBD::Oracle. http://search.cpan.org/~pythian/DBD-Oracle-1.74/lib/DBD/Oracle.pm

You can check if it's installed by executing this from the command line.

perl -MDBD::Oracle -e 1

If it's installed, you won't get any output, but if it's not installed, it will output an error message.

New User

Jul 3, 2016, 8:09 PM

Views: 8653
Re: [FishMonger] Perl web application can not connect new oracle database

Thank you for your reply. Could you please let me know where do I need to execute the command line? using cmd in the server?

Please see the code below in the common.pm file.

sub sql_do {
# run an SQL command or commands (no output is returned)
my ($sql, $plog, $tlog) = @_;
#print $plog "sql_do:\n$sql\n" if $plog;
my $sqlprint = substr($sql,0,500);
logtime($sqlprint, $plog) if $plog; # length($sql)<100;

# connect to DB
my $retry = 0;
my $dbh;
until ( $dbh = DBI->connect($pg3db, $manacc, $manword,{PrintError => 0, RaiseError =>0}) ) {
print $plog "Can't connect: $DBI::errstr. Pausing before retrying.\n";
#sleep(4) if $retry > 5;
die("Can't connect: $DBI::errstr.\n") if $retry > 5;

$dbh->do("Alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'");
$dbh->do("Alter session set current_schema=$schema");