创建连接
String url = "jdbc:phoenix:thin:url=http://ld-xxxxx-m1-ps-proxy-phoenix.hbaseue.rds.aliyuncs.com:8765;serialization=PROTOBUF";
Properties props = new Properties();
props.put("user", "root");
props.put("password", "root");
Connection pconn = DriverManager.getConnection(url, props);
pconn.setAutoCommit(true);
使用PhoenixSQL
Statement stmt = null;
try {
stmt = pconn.createStatement();
stmt.execute("create table test(c1 integer, c2 integer, constraint pk primary key(c1))");
stmt.execute("upsert into test(c1,c2) values(1,1)");
ResultSet rs = stmt.executeQuery("select * from test");
while (rs.next()) {
int c1 = rs.getInt("c1");
int c2 = rs.getInt("c2");
System.out.println("c1=" + c1 + ",c2=" + c2);
}
} catch (Throwable e) {
e.printStackTrace();
} finally {
if (stmt != null) {
stmt.close();
}
}
在文档使用中是否遇到以下问题
更多建议
匿名提交