Support Questions

Find answers, ask questions, and share your expertise

loading phoenix table using java

avatar
Expert Contributor

I wanted to load a csv file into phoenix table using Java.

I need help on JDBC phoenix connection. I am getting lots of dependencies issue.

Can someone please help me on what are the jar files reuquired to establish a jdbc connection for phoenix

1 ACCEPTED SOLUTION

avatar
Explorer

Hi @Dinesh Das,

I'm using Sandbox 2.6.1

Tips:

* You can find the phoenix version in the path: /usr/hdp/current/phoenix-client/lib/phoenix-core-{phoenix.version}.jar

* For testing purposes I'm using the following properties:

url: jdbc:phoenix:localhost:2181:/hbase-unsecure
driver-class-name: org.apache.phoenix.jdbc.PhoenixDriver
username: anything
password: anything

You need to add the following properties, dependencies and repositories to your pom file:

<properties> 
...  
<phoenix.version>4.7.0.2.6.1.0-129</phoenix.version>   
...
</properties>

<dependencies>
...
<dependency>
   <groupId>org.apache.phoenix</groupId>
   <artifactId>phoenix-core</artifactId>
   <version>${phoenix.version}</version>
</dependency>
...
</dependencies>

<repositories>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.release.repo</id>
      <name>Hortonworks Release Repository</name>
      <url>http://repo.hortonworks.com/content/repositories/releases/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.third-party.artifacts.1</id>
      <name>Hortonworks third-party artifacts 1</name>
      <url>http://repo.hortonworks.com/content/repositories/jetty-hadoop/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.third-party.artifacts.2</id>
      <name>Hortonworks third-party artifacts 2</name>
      <url>http://repo.hortonworks.com/content/repositories/re-hosted/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.public.group.repo</id>
      <name>Hortonworks Public Group Repository</name>
      <url>http://repo.hortonworks.com/content/groups/public</url>
   </repository>
</repositories>

That's all you need 🙂

View solution in original post

2 REPLIES 2

avatar
Explorer

Hi @Dinesh Das,

I'm using Sandbox 2.6.1

Tips:

* You can find the phoenix version in the path: /usr/hdp/current/phoenix-client/lib/phoenix-core-{phoenix.version}.jar

* For testing purposes I'm using the following properties:

url: jdbc:phoenix:localhost:2181:/hbase-unsecure
driver-class-name: org.apache.phoenix.jdbc.PhoenixDriver
username: anything
password: anything

You need to add the following properties, dependencies and repositories to your pom file:

<properties> 
...  
<phoenix.version>4.7.0.2.6.1.0-129</phoenix.version>   
...
</properties>

<dependencies>
...
<dependency>
   <groupId>org.apache.phoenix</groupId>
   <artifactId>phoenix-core</artifactId>
   <version>${phoenix.version}</version>
</dependency>
...
</dependencies>

<repositories>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.release.repo</id>
      <name>Hortonworks Release Repository</name>
      <url>http://repo.hortonworks.com/content/repositories/releases/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.third-party.artifacts.1</id>
      <name>Hortonworks third-party artifacts 1</name>
      <url>http://repo.hortonworks.com/content/repositories/jetty-hadoop/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.third-party.artifacts.2</id>
      <name>Hortonworks third-party artifacts 2</name>
      <url>http://repo.hortonworks.com/content/repositories/re-hosted/</url>
   </repository>
   <repository>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>false</enabled>
      </snapshots>
      <id>hortonworks.public.group.repo</id>
      <name>Hortonworks Public Group Repository</name>
      <url>http://repo.hortonworks.com/content/groups/public</url>
   </repository>
</repositories>

That's all you need 🙂

avatar
Expert Contributor

@Marco Almeida

Thank you for your help. I did try for various version of phoenix core but no luck

lemme try this..