You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Jorge Alvarado <al...@live.com> on 2022/02/03 09:28:10 UTC

using JDBC to connect to Drill

Hi Drill community,

I'm trying to connect to drill 1.19 using JDBC,

For context: I have a VM running zookeeper and another VM running drillbit.
The web UI is working fine, the queries are working fine.

In my maven dependency I have:
 <groupId>org.apache.drill.exec</groupId>
            <artifactId>drill-jdbc-all</artifactId>
            <version>1.19.0</version>

In my code:

  Connection conn = null;
            String url = "jdbc:drill:zk=<dns name of zk server in the cloud>:2181;schema=common1";
            String query = "SELECT * FROM `common1`.`products.json` LIMIT 10";
            Statement stmt = null;
            ResultSet result = null;

            conn = DriverManager.getConnection(url);
            stmt = conn.createStatement();
            result = null;
            String column1,column2;
            result = stmt.executeQuery(query);


When I run the console app I have  a bunch of errors but the most prominent is:
CONNECTION : java.net.UnknownHostException: drill3.internal.cloudapp.net: Name or service not known

drill3.internal.cloudapp.net is exactly the name that appears on the drill web UI for my only drillbit node.
It makes sense that it cannot resolve as it looks like an internal address so what I updated my hosts file (on my dev pc) to resolve the public ip address of the drill node, but it still gives me the same error.

Do you have any ideas how to make my Java app to resolve the internal address?

thanks in advance

Jorge


AW: Re: using JDBC to connect to Drill

Posted by Z0ltrix <z0...@pm.me.INVALID>.
sure, i´ll create a PR in the next days

------- Original Message -------

luoc <lu...@apache.org> schrieb am Donnerstag, 3. Februar 2022 um 11:55:

> Hi Christian,
> 

> Is it possible to add this tips to the docs? It is recommended that we add it to the "Troubleshooting" section, thanks!
> 

> https://drill.apache.org/docs/troubleshooting/
> 

> > On Feb 3, 2022, at 18:46, Z0ltrix z0ltrix@pm.me.invalid wrote:
> > 

> > Christian

AW: Re: using JDBC to connect to Drill

Posted by Z0ltrix <z0...@pm.me.INVALID>.
sure, i´ll create a PR in the next days

------- Original Message -------

luoc <lu...@apache.org> schrieb am Donnerstag, 3. Februar 2022 um 11:55:

> Hi Christian,
> 

> Is it possible to add this tips to the docs? It is recommended that we add it to the "Troubleshooting" section, thanks!
> 

> https://drill.apache.org/docs/troubleshooting/
> 

> > On Feb 3, 2022, at 18:46, Z0ltrix z0ltrix@pm.me.invalid wrote:
> > 

> > Christian

Re: using JDBC to connect to Drill

Posted by luoc <lu...@apache.org>.
Hi Christian,
  Is it possible to add this tips to the docs? It is recommended that we add it to the "Troubleshooting" section, thanks!

https://drill.apache.org/docs/troubleshooting/

> On Feb 3, 2022, at 18:46, Z0ltrix <z0...@pm.me.invalid> wrote:
> 
> Christian

Re: using JDBC to connect to Drill

Posted by luoc <lu...@apache.org>.
Hi Christian,
  Is it possible to add this tips to the docs? It is recommended that we add it to the "Troubleshooting" section, thanks!

https://drill.apache.org/docs/troubleshooting/

> On Feb 3, 2022, at 18:46, Z0ltrix <z0...@pm.me.invalid> wrote:
> 
> Christian

AW: Re: using JDBC to connect to Drill

Posted by Z0ltrix <z0...@pm.me.INVALID>.
Hi Jorge,

its all about dns...

One solution is to configure /etc/hosts on each machine correctly, so that each server can reach the others by address resolution.

the other trick is to set the internal IP address of the drillbit as hostname in drill-env.sh
export DRILL_HOST_NAME=`10.x.x.x`

Drill uses this to register itself within zookeeper and gives this information back to the client.

Regards 

Christian

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

luoc <lu...@apache.org> schrieb am Donnerstag, 3. Februar 2022 um 11:28:

> Hi Jorge,
> 

> It seems that we have answered this question before. Let me find it first..
> 

> https://github.com/apache/drill/issues/2415
> 

> > On Feb 3, 2022, at 17:28, Jorge Alvarado alvaradojl@live.com wrote:
> > 

> > Hi Drill community,
> > 

> > I'm trying to connect to drill 1.19 using JDBC,
> > 

> > For context: I have a VM running zookeeper and another VM running drillbit.
> > 

> > The web UI is working fine, the queries are working fine.
> > 

> > In my maven dependency I have:
> > 

> > <groupId>org.apache.drill.exec</groupId>
> > 

> > <artifactId>drill-jdbc-all</artifactId>
> > 

> > <version>1.19.0</version>
> > 

> > In my code:
> > 

> > Connection conn = null;
> > 

> > String url = "jdbc:drill:zk=<dns name of zk server in the cloud>:2181;schema=common1";
> > 

> > String query = "SELECT * FROM `common1`.`products.json` LIMIT 10";
> > 

> > Statement stmt = null;
> > 

> > ResultSet result = null;
> > 

> >            conn = DriverManager.getConnection(url);
> >            stmt = conn.createStatement();
> >            result = null;
> >            String column1,column2;
> >            result = stmt.executeQuery(query);
> >     

> > 

> > When I run the console app I have a bunch of errors but the most prominent is:
> > 

> > CONNECTION : java.net.UnknownHostException: drill3.internal.cloudapp.net: Name or service not known
> > 

> > drill3.internal.cloudapp.net is exactly the name that appears on the drill web UI for my only drillbit node.
> > 

> > It makes sense that it cannot resolve as it looks like an internal address so what I updated my hosts file (on my dev pc) to resolve the public ip address of the drill node, but it still gives me the same error.
> > 

> > Do you have any ideas how to make my Java app to resolve the internal address?
> > 

> > thanks in advance
> > 

> > Jorge

AW: Re: using JDBC to connect to Drill

Posted by Z0ltrix <z0...@pm.me.INVALID>.
Hi Jorge,

its all about dns...

One solution is to configure /etc/hosts on each machine correctly, so that each server can reach the others by address resolution.

the other trick is to set the internal IP address of the drillbit as hostname in drill-env.sh
export DRILL_HOST_NAME=`10.x.x.x`

Drill uses this to register itself within zookeeper and gives this information back to the client.

Regards 

Christian

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

luoc <lu...@apache.org> schrieb am Donnerstag, 3. Februar 2022 um 11:28:

> Hi Jorge,
> 

> It seems that we have answered this question before. Let me find it first..
> 

> https://github.com/apache/drill/issues/2415
> 

> > On Feb 3, 2022, at 17:28, Jorge Alvarado alvaradojl@live.com wrote:
> > 

> > Hi Drill community,
> > 

> > I'm trying to connect to drill 1.19 using JDBC,
> > 

> > For context: I have a VM running zookeeper and another VM running drillbit.
> > 

> > The web UI is working fine, the queries are working fine.
> > 

> > In my maven dependency I have:
> > 

> > <groupId>org.apache.drill.exec</groupId>
> > 

> > <artifactId>drill-jdbc-all</artifactId>
> > 

> > <version>1.19.0</version>
> > 

> > In my code:
> > 

> > Connection conn = null;
> > 

> > String url = "jdbc:drill:zk=<dns name of zk server in the cloud>:2181;schema=common1";
> > 

> > String query = "SELECT * FROM `common1`.`products.json` LIMIT 10";
> > 

> > Statement stmt = null;
> > 

> > ResultSet result = null;
> > 

> >            conn = DriverManager.getConnection(url);
> >            stmt = conn.createStatement();
> >            result = null;
> >            String column1,column2;
> >            result = stmt.executeQuery(query);
> >     

> > 

> > When I run the console app I have a bunch of errors but the most prominent is:
> > 

> > CONNECTION : java.net.UnknownHostException: drill3.internal.cloudapp.net: Name or service not known
> > 

> > drill3.internal.cloudapp.net is exactly the name that appears on the drill web UI for my only drillbit node.
> > 

> > It makes sense that it cannot resolve as it looks like an internal address so what I updated my hosts file (on my dev pc) to resolve the public ip address of the drill node, but it still gives me the same error.
> > 

> > Do you have any ideas how to make my Java app to resolve the internal address?
> > 

> > thanks in advance
> > 

> > Jorge

Re: using JDBC to connect to Drill

Posted by luoc <lu...@apache.org>.
Hi Jorge,
It seems that we have answered this question before. Let me find it first..

https://github.com/apache/drill/issues/2415

> On Feb 3, 2022, at 17:28, Jorge Alvarado <al...@live.com> wrote:
> 
> Hi Drill community,
> 
> I'm trying to connect to drill 1.19 using JDBC,
> 
> For context: I have a VM running zookeeper and another VM running drillbit.
> The web UI is working fine, the queries are working fine.
> 
> In my maven dependency I have:
> <groupId>org.apache.drill.exec</groupId>
>            <artifactId>drill-jdbc-all</artifactId>
>            <version>1.19.0</version>
> 
> In my code:
> 
>  Connection conn = null;
>            String url = "jdbc:drill:zk=<dns name of zk server in the cloud>:2181;schema=common1";
>            String query = "SELECT * FROM `common1`.`products.json` LIMIT 10";
>            Statement stmt = null;
>            ResultSet result = null;
> 
>            conn = DriverManager.getConnection(url);
>            stmt = conn.createStatement();
>            result = null;
>            String column1,column2;
>            result = stmt.executeQuery(query);
> 
> 
> When I run the console app I have  a bunch of errors but the most prominent is:
> CONNECTION : java.net.UnknownHostException: drill3.internal.cloudapp.net: Name or service not known
> 
> drill3.internal.cloudapp.net is exactly the name that appears on the drill web UI for my only drillbit node.
> It makes sense that it cannot resolve as it looks like an internal address so what I updated my hosts file (on my dev pc) to resolve the public ip address of the drill node, but it still gives me the same error.
> 
> Do you have any ideas how to make my Java app to resolve the internal address?
> 
> thanks in advance
> 
> Jorge
> 
> 

Re: using JDBC to connect to Drill

Posted by luoc <lu...@apache.org>.
Hi Jorge,
It seems that we have answered this question before. Let me find it first..

https://github.com/apache/drill/issues/2415

> On Feb 3, 2022, at 17:28, Jorge Alvarado <al...@live.com> wrote:
> 
> Hi Drill community,
> 
> I'm trying to connect to drill 1.19 using JDBC,
> 
> For context: I have a VM running zookeeper and another VM running drillbit.
> The web UI is working fine, the queries are working fine.
> 
> In my maven dependency I have:
> <groupId>org.apache.drill.exec</groupId>
>            <artifactId>drill-jdbc-all</artifactId>
>            <version>1.19.0</version>
> 
> In my code:
> 
>  Connection conn = null;
>            String url = "jdbc:drill:zk=<dns name of zk server in the cloud>:2181;schema=common1";
>            String query = "SELECT * FROM `common1`.`products.json` LIMIT 10";
>            Statement stmt = null;
>            ResultSet result = null;
> 
>            conn = DriverManager.getConnection(url);
>            stmt = conn.createStatement();
>            result = null;
>            String column1,column2;
>            result = stmt.executeQuery(query);
> 
> 
> When I run the console app I have  a bunch of errors but the most prominent is:
> CONNECTION : java.net.UnknownHostException: drill3.internal.cloudapp.net: Name or service not known
> 
> drill3.internal.cloudapp.net is exactly the name that appears on the drill web UI for my only drillbit node.
> It makes sense that it cannot resolve as it looks like an internal address so what I updated my hosts file (on my dev pc) to resolve the public ip address of the drill node, but it still gives me the same error.
> 
> Do you have any ideas how to make my Java app to resolve the internal address?
> 
> thanks in advance
> 
> Jorge
> 
>