#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2

    Connecting to a database on JavaDB/Derby Server


    Hi,

    I have written scripts to connect to sql databases using perl.

    But now we have a database on a JavaDB/Derby server using jdbc driver.

    I am not very famliar with this driver and if we can connect to it using perl.

    Any pointers or sample code anyone can give.

    Many Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,875
    Rep Power
    1225
    I have not used it but here's the DBD module you need.

    DBD::JDBC - JDBC proxy driver for the DBI module
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2
    Thanks a lot.

    I will look into this module.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2
    I went through the documentation on web on downloading DBD::JDBC but was not able to. Facing issue downloading isng ppm.

    Has anyone installed this module and if so any suggestions ?
  8. #5
  9. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,221
    Rep Power
    1809
    DBD::JDBC doesn't look like a well maintained module.

    I haven't used Derby at all, but I saw this article at the IBM site which says you can use ODBC to connect to Derby instead of JDBC. Might give that a try.

    Develop Perl applications with Apache Derby
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2
    Thanks - I will look through this article.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2
    I tried using the link below :

    http://wiki.apache.org/db-derby/DerbyAndPerlWithDBDJDBC



    As per this link I was able to get the dbd_jdbc server started using :



    java -Djdbc.drivers=org.apache.derby.EmbeddedDriver \
    -Ddbd.port=12345 \
    -classpath db-derby-10.5.1.1-lib/lib/derby.jarBD-JDBC-0.71/dbd_jdbc.jar:apache-log4j-1.2.15/log4j-1.2.15.jar \
    com.vizdom.dbd.jdbc.Server





    So on the prompt it says Server accepting connection.



    And than I try the below perl code



    use DBD::JDBC;

    $url = "jdbc:derby://10.10.135.25:1523/dbname;user=xyz;password=abc";
    ## 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:12345;url=$url";

    $dbh = DBI->connect($dsn, undef, undef, undef);

    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";
    }


    But this hangs after making the connection.

    any ideas ?

    Thanks
  14. #8
  15. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,221
    Rep Power
    1809
    Since the JDBC driver for perl is so old and unmaintained, my idea was that you try the ODBC one instead, using the information in that link I provided.

    The JDBC module doesn't look promising based on the CPAN test data: CPAN Testers Matrix
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    31
    Rep Power
    2
    Thank you

IMN logo majestic logo threadwatch logo seochat tools logo