2006-01-18

Use DBD: :Oracle 1.16 to access Oracle 9.2 database

I try to connect to an Oracle 9.2 database using following code:
 my $dbh = DBI->connect($config->{dburl}, $config->{dbuser}, $config->{dbpass});

It failed with error:
DBI connect('host=host;sid=dbsid','user',...) failed: ORA-12705: invalid or unknown NLS parameter value specified (DBD ERROR: OCISessionBegin) at ..

I have to explicitly set the ENV variable NLS_LANG to make it work. The new code looks like:
$ENV{NLS_LANG}="AMERICAN_AMERICA.UTF8";
my $dbh = DBI->connect($config->{dburl}, $config->{dbuser}, $config->{dbpass});

and it works.

The initial thought is that the default NLS_LANG from DBD::Oracle has to match the server configuration which is "AMERICAN_AMERICA.UTF8". But the follwoing code works as well:
$ENV{NLS_LANG}="AMERICAN_AMERICA.US7ASCII";
my $dbh = DBI->connect($config->{dburl}, $config->{dbuser}, $config->{dbpass});

So maybe the DBD:Oracle is sending some invalid NLS_LANG string though I havn't figured out what it is.

The SimpleDateFormat class is NOT threadsafe

In researching a defect in my project, I find SimpleDateFormat class is not thread safe. The "bug" is reported back in JDK 1.2 and JavaDoc is added in JDK 1.5. I just don't see it. :(