jainprithviraj has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am getting below error while connecting to Derby DB from my perl script. I could connect to Derby BY without using my script.
[root@prithvi bin]# perl tmp.pl DBI connect('hostname=localhost;port=1527;url=jdbc:derby:mydb%3Bsecuri +tyMechanism%3D8','myuser',...) failed: I/O Error 001bd00200010015124 +c0006114900080006000c00000005114a03 at tmp.pl line 9 Derby system tables -------------------------- Can't call method "prepare" on an undefined value at tmp.pl line 12. [root@prithvi bin]# [root@prithvi bin]# [root@prithvi bin]# cat tmp.pl use DBD::JDBC; $url = "jdbc:derby:mydb;securityMechanism=8"; ## Since space, ';' and '=' is used in DBD dsn, ## we need to encode them in the url: $url =~ s/([=;])/uc sprintf("%%%02x",ord($1))/eg; $dsn = "dbi:JDBC:hostname=localhost;port=1527;url=$url"; $dbh = DBI->connect($dsn, "myuser", "mypassword"); print "Derby system tables\n--------------------------\n"; $sth = $dbh->prepare("select tablename from SYS.SYSTABLES"); $sth->execute(); while (my ($i) = $sth->fetchrow_array) { print "Found: $i\n"; } [root@prithvi bin]# [root@prithvi bin]# /opt/Java/jdk1.6.0_21/db/bin/ij ij version 10.5 ij> connect 'jdbc:derby://localhost:1527/mydb;securityMechanism=8;user +=myuser;password=mypassword'; ij>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error connecting to Derby DB
by Corion (Patriarch) on Apr 09, 2011 at 08:38 UTC | |
by jainprithviraj (Initiate) on Apr 09, 2011 at 08:52 UTC | |
by Corion (Patriarch) on Apr 09, 2011 at 15:38 UTC | |
by jainprithviraj (Initiate) on Apr 10, 2011 at 08:36 UTC | |
by Corion (Patriarch) on Apr 10, 2011 at 08:46 UTC |