drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rahul challapalli <challapallira...@gmail.com>
Subject Re: Unable to connect to drill 1.1.0 using JDBC
Date Mon, 27 Jul 2015 22:36:18 GMT
I am hitting the same issue as well. Filed the below jira and marked it as
a blocker

https://issues.apache.org/jira/browse/DRILL-3566

- Rahul

On Mon, Jul 27, 2015 at 12:24 AM, Anas Mesrah <anas.mesrah@gmail.com> wrote:

> Here's a simple test case that reproduces the issue
>
>
> import java.sql.Connection;
> import java.sql.PreparedStatement;
> import java.sql.ResultSet;
> import java.util.Properties;
>
> import org.apache.drill.jdbc.Driver;
> import org.junit.Assert;
> import org.junit.Test;
>
> public class TestDrillConnect {
>
>     @Test
>     public void testDrillJdbcDriver() throws Exception {
>         Connection con = null;
>         PreparedStatement stmt = null;
>         ResultSet rs = null;
>
>         try {
>             con = new Driver().connect(DRILL_JDBC_LOCAL_URI,
> getDefaultProperties());
>             stmt = con.prepareStatement(DRILL_SAMPLE_QUERY);
>             rs = stmt.executeQuery();
>
>             int count = 0;
>             while (rs.next()) {
>                 System.err.println(rs.getString(1));
>                 System.err.println(rs.getString(2));
>                 System.err.println(rs.getString(3));
>                 count++;
>             }
>             Assert.assertEquals("Twenty rows were expected.", count, 20);
>         } catch (ClassCastException ex) {
>             Assert.fail("ClassCastException was thrown: " +
> ex.getMessage());
>         } catch (Exception ex) {
>             System.out.println(ex);
>
>         } finally {
>             if (rs != null) rs.close();
>             if (stmt != null) stmt.close();
>             if (con != null) con.close();
>         }
>     }
>
>     public static Properties getDefaultProperties() {
>         final Properties properties = new Properties();
>         properties.setProperty("user", USER);
>         properties.setProperty("password", PASSWORD);
>         return properties;
>     }
>
>     /* Drill JDBC Uri for local zookeeper */
>     public static final String DRILL_JDBC_LOCAL_URI =
> "jdbc:drill:zk=localhost:2181";
>
>     /* user */
>     public static final String USER = "admin";
>
>     /* password */
>     public static final String PASSWORD = "admin";
>
>     /* Sample query used by Drill */
>     public static final String DRILL_SAMPLE_QUERY = "SELECT * FROM
> cp.`employee.json` LIMIT 20";
>
> }
>
>
> On Mon, Jul 27, 2015 at 8:44 AM, Anas Mesrah <anas.mesrah@gmail.com>
> wrote:
>
> > Adding dev group. Hope someone can help.
> >
> > I may help but I am unable where to start. I am not sure where or how the
> > statement is being created. Can someone please guide me how to
> investigate
> > the issue?
> >
> > On Sun, Jul 26, 2015 at 7:35 PM, Yash Sharma <yash360@gmail.com> wrote:
> >
> >> Hey,
> >> I hit the ClassNotFound with prepared statement as well. Would explore
> it
> >> and revert back.
> >> Meanwhile other contributors can suggest a workaround.
> >>
> >> Best
> >>
> >> On Sun, Jul 26, 2015 at 10:06 PM, Anas Mesrah <anas.mesrah@gmail.com>
> >> wrote:
> >>
> >> > Thanks Yash for your swift response.  Appreciate it.
> >> >
> >> > We want to connect using JDBC not in the embedded mode. Your code
> worked
> >> > fine and you are using createStatement. However, we are trying to use
> >> > prepareStatement.
> >> > Once we changed that, our code worked fine as well.
> >> >
> >> > Is there a way to make prepareStatement work with 1.1.0?
> >> >
> >> >
> >> >
> >> > On Sun, Jul 26, 2015 at 6:18 PM, Yash Sharma <yash360@gmail.com>
> wrote:
> >> >
> >> > > Just to add on, Here is a quick code I use to connect to Drill. Hope
> >> it
> >> > > helps-
> >> > >
> >> > > https://gist.github.com/yssharma/8b72557ad23f080e7c1f
> >> > >
> >> > > Best
> >> > >
> >> > > On Sun, Jul 26, 2015 at 9:44 PM, Yash Sharma <yash360@gmail.com>
> >> wrote:
> >> > >
> >> > > > Hi Ahmed,
> >> > > > Could you paste the code here or in pastebin/gist.
> >> > > > Mail attachments do not work.
> >> > > >
> >> > > > Best
> >> > > >
> >> > > > On Sun, Jul 26, 2015 at 9:22 PM, Anas Mesrah <
> anas.mesrah@gmail.com
> >> >
> >>
> >> > > > wrote:
> >> > > >
> >> > > >> Hi All,
> >> > > >>
> >> > > >> We have been able to connect peacefully to drill 0.8.0 using
> JDBC.
> >> > When
> >> > > >> we tried to upgrade and use the latest jsdbc driver, we got
the
> >> > > following
> >> > > >> eception:
> >> > > >>
> >> > > >>> Exception in thread "main" java.lang.ClassCastException:
> >> > > >>>
> >> > >
> >> >
> >>
> org.apache.drill.jdbc.impl.DrillJdbc41Factory$DrillJdbc41PreparedStatement
> >> > > >>> cannot be cast to org.apache.drill.jdbc.impl.DrillStatementImpl
> >> > > >>> at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newResultSet(
> >> > > >>> DrillJdbc41Factory.java:106)
> >> > > >>> at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newResultSet(
> >> > > >>> DrillJdbc41Factory.java:1)
> >> > > >>> at
> net.hydromatic.avatica.AvaticaConnection.executeQueryInternal(
> >> > > >>> AvaticaConnection.java:397)
> >> > > >>> at net.hydromatic.avatica.AvaticaPreparedStatement.executeQuery(
> >> > > >>> AvaticaPreparedStatement.java:77)
> >> > > >>> at com.incorta.trails.DrillTest.query(DrillTest.java:33)
> >> > > >>> at com.incorta.trails.DrillTest.main(DrillTest.java:12)
> >> > > >>
> >> > > >> The original code still connects to 0.8.0 without errors.
> Attached
> >> the
> >> > > >> java test file that I used to replicate the problem.
> >> > > >>
> >> > > >> Appreciate anyone's help to resolve this issue.
> >> > > >>
> >> > > >> Thanks
> >> > > >> --
> >> > > >>
> >> > > >> *Best Regards,*
> >> > > >>
> >> > > >> *Anas Mosaad ** <
> https://eg.linkedin.com/pub/anas-mesrah/1b/93/60a
> >> >*
> >> > > >> *Senior Software Engineer, *
> >> > > >> *Incorta Inc*
> >> > > >> *Mob. +201007434510*
> >> > > >>
> >> > > >>
> >> > > >>
> >> > > >
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >> > *Best Regards,*
> >> >
> >> > *Anas Mosaad ** <https://eg.linkedin.com/pub/anas-mesrah/1b/93/60a>*
> >> > *Senior Software Engineer, *
> >> > *Incorta Inc*
> >> > *Mob. +201007434510*
> >> >
> >>
> >
> >
> >
> > --
> >
> > *Best Regards,*
> >
> > *Anas Mosaad ** <https://eg.linkedin.com/pub/anas-mesrah/1b/93/60a>*
> > *Senior Software Engineer, *
> > *Incorta Inc*
> > *Mob. +201007434510 <%2B201007434510>*
> >
> >
> >
>
>
> --
>
> *Best Regards,*
>
> *Anas Mosaad ** <https://eg.linkedin.com/pub/anas-mesrah/1b/93/60a>*
> *Senior Software Engineer, *
> *Incorta Inc*
> *Mob. +201007434510*
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message