Member since
03-18-2016
1
Post
1
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
5266 | 05-24-2016 09:43 AM |
05-24-2016
09:43 AM
1 Kudo
Hi @nejm hadjmbarek, I'm Posting my code, which is working Fine: import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
public class phoenix_hbase
{
public static void main(String[] args) throws SQLException
{
@SuppressWarnings("unused")
Statement stmt = null;
ResultSet rset = null;
try
{
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
}
catch (ClassNotFoundException e1)
{
System.out.println("Exception Loading Driver");
e1.printStackTrace();
}
try
{
Connection con = DriverManager.getConnection("jdbc:phoenix:172.31.124.43:2181:/hbase-unsecure"); //172.31.124.43 is the adress of VM, not needed if ur running the program from vm itself
stmt = con.createStatement();
PreparedStatement statement = con.prepareStatement("select * from javatest");
rset = statement.executeQuery();
while (rset.next())
{
System.out.println(rset.getString("mycolumn"));
}
statement.close();
con.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
... View more