Skip to content

Commit

Permalink
加入Phoenix原生api例子,调整pom
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyofin committed Jul 2, 2019
1 parent 8ff3091 commit 7350345
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions hbase-starter/src/main/java/phoenix/PhoenixTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package phoenix;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
* 直接使用原生jdbc访问Phoenix
*/
public class PhoenixTest {

public static void main(String[] args) throws Exception {
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
// 写上zookeeper地址
Connection connection = DriverManager.getConnection("jdbc:phoenix:localhost:2181");

PreparedStatement statement = connection.prepareStatement("select * from TEST");

ResultSet resultSet = statement.executeQuery();

while (resultSet.next()) {
System.out.println(resultSet.getString("MYCOLUMN"));
}

statement.close();
connection.close();
}
}
3 changes: 2 additions & 1 deletion hbase-starter/src/test/java/phoenix_mybatis/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import java.util.List;

/**
* on 18-3-11.
* 需要手动在Phoenix中创建USER_INFO表
* create table USER_INFO (id integer not null primary key, name varchar);
*/
@RunWith(SpringJUnit4ClassRunner.class)
@Import(PhoenixDataSourceConfig.class)
Expand Down

0 comments on commit 7350345

Please sign in to comment.