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>

In reply to Error connecting to Derby DB by jainprithviraj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.