我想开始有没有凤凰Hello World?
先决条件:从这里下载最新的凤凰,将凤凰 - *。jar复制到HBase lib文件夹并重启HBase。
1.使用控制台
开始Sqlline:$ sqlline.py [zookeeper]当Sqlline连接时执行以下语句:create table test (mykey integer not null primary key, mycolumn varchar); upsert into test values (1,'Hello'); upsert into test values (2,'World!'); select * from test;
您应该得到以下输出+-------+------------+ | MYKEY | MYCOLUMN | +-------+------------+ | 1 | Hello | | 2 | World! | +-------+------------+
2.使用java
创建具有以下内容的test.java文件:
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 test { public static void main(String[] args) throws SQLException { Statement stmt = null; ResultSet rset = null; Connection con = DriverManager.getConnection("jdbc:phoenix:[zookeeper]"); stmt = con.createStatement(); stmt.executeUpdate("create table test (mykey integer not null primary key, mycolumn varchar)"); stmt.execute