It should work with a local/embedded drill as well, as the tests for the
JDBC driver run against a local drill instance. I'm adding the dev mailing
list to this thread in the hopes that someone can help me understand what
the properties set on this line
<https://github.com/apache/drill/blob/e3ab2c1760ad34bda80141e2c3108f7eda7c9104/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java#L53-53>
are doing exactly, as that seems to be the only difference between my
snippet and the tests. Should I be setting them if I want to use Drill in
embedded/local mode over JDBC? Is there a way to generate the models file
<https://github.com/apache/drill/blob/e3ab2c1760ad34bda80141e2c3108f7eda7c9104/exec/jdbc/src/test/resources/test-models.json>
?

Any help is appreciated!

Denys

On Wed, Jan 28, 2015 at 5:55 PM, Carol McDonald <[email protected]>
wrote:

> I think jdbc requires zookeeper (?). The following works with drill on the
> mapr sandbox:
>
>     public static void main(String[] args) throws Exception {
>         String driver = "org.apache.drill.jdbc.Driver";
>         String url =
> "jdbc:drill:zk=maprdemo:5181/drill/demo_mapr_com-drillbits";
>         String username = "mapr";
>         String password = "mapr";
>         Class.forName(driver);
>         Connection con = DriverManager.getConnection(url, username,
> password);
>         Statement stmt = con.createStatement();
>         ResultSet rs = stmt.executeQuery("SELECT * FROM dfs.views.custview
> limit 5");
>         ResultSetMetaData rsmd = rs.getMetaData();
>         int numberOfColumns = rsmd.getColumnCount();
>
>         for (int i = 1; i <= numberOfColumns; i++) {
>             System.out.print(rsmd.getColumnName(i) + "  ");
>         }
>         System.out.println("");
>
>         while (rs.next()) {
>             for (int i = 1; i <= numberOfColumns; i++) {
>                 System.out.print(rs.getString(i)+ "  ");
>             }
>             System.out.println("");
>         }
>         stmt.close();
>         con.close();
>     }
>
> }
>
> On Wed, Jan 28, 2015 at 5:39 PM, Denys Pavlov <[email protected]>
> wrote:
>
> > Hi all,
> >
> > I am trying to use Drill programmatically in Java through the JDBC
> driver.
> > However, when I try to execute the query, the application hangs and never
> > returns the ResultSet. When I execute the exact same query in sqlline,
> > everything executes fine.
> >
> > The code snippet is below and should work with no configuration in
> > /tmp/drill.
> >
> > public class DrillJDBCTestTrial {
> >     public static void main(String[] args) throws SQLException,
> > ClassNotFoundException {
> >         Class.forName("org.apache.drill.jdbc.Driver");
> >         Connection connection =
> > DriverManager.getConnection("jdbc:drill:zk=local");
> >         String query = "select N_NAME from
> >
> >
> dfs.`/home/meatcar/dev/drill/apache-drill-0.7.0/sample-data/nation.parquet`";
> >
> >         PreparedStatement statement = connection.prepareStatement(query);
> >
> >         // hangs here
> >         ResultSet rs = statement.executeQuery();
> >     }
> > }
> >
> > Any help is appreciated.
> >
> >
> > Thanks,
> >
> > --
> > Denys Pavlov
> >
>



-- 
Denys Pavlov

Reply via email to