1 <dependency> 2 <groupId>org.apache.phoenix</groupId> 3 <artifactId>phoenix-core</artifactId> 4 <version>5.0.0-HBase-2.0</version> 5 </dependency>
除此之外还需要导入phoenix-5.0.0-HBase-2.0-client.jar
把以下文件拷贝到resources文件夹下
1 public class Demo { 2 public static void main(String[] args) throws SQLException { 3 Connection connection = BaseDB.getConnection(); 4 5 String sql = "select * from test"; 6 PreparedStatement prepareStatement = connection.prepareStatement(sql); 7 ResultSet rs = prepareStatement.executeQuery(); 8 while (rs.next()) { 9 System.out.println(rs.getInt(1)); 10 System.err.println(rs.getString(2)); 11 } 12 13 } 14 } 15 public class BaseDB { 16 public static Connection getConnection() { 17 try { 18 Class.forName("org.apache.phoenix.jdbc.PhoenixDriver"); 19 return DriverManager.getConnection("jdbc:phoenix"); 20 } catch (Exception e) { 21 e.printStackTrace(); 22 return null; 23 } 24 } 25 }
原文地址:https://www.cnblogs.com/tele-share/p/10805044.html
时间: 2024-10-11 03:30:27