spragues has asked for the wisdom of the Perl Monks concerning the following question:

All who dare to read,

I know this is a long shot but i'm out of ideas so i joined this group of misfits and now seek the advice of the Oracle.

Short back story.

I'm using Apache/Phoenix to query Apache/HBase data. I presume most of you out there have heard of HBase but less of you have heard of Phoenix. Phoenix is slick sql wrapper (openSourced by Salesforce.com) over HBase. All this is good. The hitch is its all Java (naturally.) However, they have made a JDBC driver available (hooray.) I can and do use DBD::JDBC to run sql commands to interact with it. This works out Pretty Dang Well(tm).

Why then do i seek the Oracle?

Two pesky meta commands I can't for the life of me figure out how to make work.

1. show tables

2. show databases

DBD::DBI has $dbh->tables but DBD::JDBC does not implement it. boo-hiss. So then i rolled up my sleeves and started looking at $dbh->jdbc_func() calls after reading the jdbc doc on how to list metadata. Alas, all my attempts have failed.

this is the one that had the most promise i thought:

1. $dbh->jdbc_func("%", "%", "%", "%", jdbc_getMetaData.getTables");
but it yields:
Fri Apr 4 13:46:00 2014 - error encountered: DBD::JDBC::db jdbc_func +failed: com.vizdom.dbd.jdbc.DbdException: Reflection exception: Unabl +e to invoke method

So after all that i realize its a pretty specialized question but i'm hoping, just maybe, i might get lucky and find some other poor schmuck that has been forced to used JDBC from perl... that maybe has been down this road before me. Any takers?

Thank you!

Replies are listed 'Best First'.
Re: DBD::JDBC craziness
by basiliscos (Pilgrim) on Apr 05, 2014 at 11:46 UTC

    I can advice you just to check whether the required methods work in pure java, i.e. write an simple java cli-app, that checks available tables and databases. Here is a small snapshots of java-code, that queries for DB-meta information using JDBC.

    import java.sql.Connection; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource; private static DataSource getDataSource(){ String login = "root", pwd = "kne"; String url = "jdbc:mysql://localhost:3306/test"; BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUsername(login); ds.setPassword(pwd); ds.setUrl(url); return ds; } private static Object show(ResultSet rs, String title) throws Exce +ption{ Object r = null; System.out.println("[showing " + title + "]"); ResultSetMetaData rsmd = rs.getMetaData(); while(rs.next()){ for(int c = 1; c <= rsmd.getColumnCount(); c++){ String name = rsmd.getColumnName(c); Object value = rs.getObject(c); System.out.println(name + " : " + value); if(r == null){ r = value; } } } System.out.println(); return r; } public static void main(String[] args) throws Exception{ DataSource ds = getDataSource(); Connection con = ds.getConnection(); DatabaseMetaData dbMetaData = con.getMetaData(); ResultSet catalogs = dbMetaData.getCatalogs(); String catalog = (String)show(catalogs, "catalogs"); ResultSet schemas = dbMetaData.getSchemas(); String schema = (String)show(schemas, "schemas"); ResultSet tables = dbMetaData.getTables("test", null, "", null +); show(tables, "tables"); System.out.println("ok"); }

    So, you should validate, that JDBC driver you provide, actually works, and supports metainformation retrieval. As altenative you can download SQuirrelSQL, attach your jdbc-drivers for Phoenix, and check, that it actually works.

    So, it might be, that HBase or Phoenix, or JDBC driver does not support some operations. Only after assertion of that, you should look at perl's DBD::JDBC

    PS. Too much bridges/layers!

      thank you. for sure the phoenix jar file provides the getMetaData method. And like you say just way too many layers going on here.

      so i guess that begs the question. if a jdbc driver exists how does one go about actually writing a legitimate perl driver that leverages it, say in this case, DBD::Phoenix?

      something tells me - PUNT! :(

      thanks again for responding!