Tag Archives: DBI

Perl DBI error

By prasperl

Hi All,
I installed DBI module in a non INC location and using it in my script via “use lib”.
But it throw the below error at the “use DBI” step.
Please help

Code:

Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line 500.
Compilation failed in require at tokens.pl line 7.
BEGIN failed--compilation aborted at tokens.pl line 7.
Usage: DBD::_::common::trace_msg(sv, msg, this_trace=1) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm line 517.
END failed--call queue aborted at tokens.pl line 7.


…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

PERL annoying scope problem

By yifangt

Hello,
I met a problem with following code:

Code:

#!/usr/bin/perl -w
# test.pl

use strict;
use diagnostics;
use DBI;

my $dbh = DBI->connect(
"DBI:mysql:BibleBook","yifangt","password")
or die("Cannot connect: $DBI::errstr");

my $sql = qq(SELECT * FROM library WHERE isbn = '1234512345');

my $sth = $dbh->prepare($sql);

$sth->execute;

while(my $record = $sth->fetch){
for my $field (@$record){
print "$fieldn";
}
print "nn";
}


which looks fine and was running successfully except an warning message:

Code:

"Use of uninitialized value $field in concatenation (.) or string at test.pl line 20. "


The diagnostics tells me the problem is with line 20 and I googled around and, found it is a very popular scope problem with $field, which actually should be related to @$record. But,
1)$record was declared, so was $field;
2)how the scope change within the while and for loops, or/and outside the while loop? which is what I am not sure about;
3) the interesting thing is not every line of the loop issued the same warning. Why?
Can anybody tell me exactly what was wrong in my case and the correct way to eliminate this warning?
Thanks a lot!

Source: FULL ARTICLE at The UNIX and Linux Forums

Classpath of JAVA

By yifangt

Hello,
ABC question as I could not get a direct answer: How to locate the default IO class of JAVA? My question was triggered by the row in most java program

Code:

import java.io.*


as I am very curious where the io class is located in my Mint14 (Ubuntu12.10). I am aware it is similar to use DBI in PERL, or #include in C++, where I could locate the packages/libraries in certain directories:

Code:

/usr/lib/perl5/DBI.pm
/usr/include/c++/4.7/iostream


but I could not locate any file name (io.class, or io.jre) for this io class in java? Have checked my system for the libraries:

Code:

/usr/lib/jvm/java-7-openjdk-amd64/lib/
/usr/lib/jvm/java-7-openjdk-common/jre/lib/
/home/kevin/downloadsoftware/jre1.7.0_10/lib/
/usr/lib/eclipse/plugins/


Also checked Oracle website, where there is:

Code:

package java.io


but I could not find this file in my system, and the java program works fine. Can anybody give me some explanantion about the “default IO, file, string, date & time, etc classes” of java1.7.x when it was installed. My java is:

Code:

$java -version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)


Thanks a lot!

Source: FULL ARTICLE at The UNIX and Linux Forums