commit 2201f7bfef056a20cd41f463a57891d6c274d582 Author: wangran <3189505710@qq.com> Date: Wed Jan 7 09:23:54 2026 +0800 初始化项目 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..acb7754 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr +.idea + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b952b8f --- /dev/null +++ b/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + com.bigdata + phoenix0106 + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + + org.apache.phoenix + phoenix-client-hbase-2.4 + 5.1.2 + + + \ No newline at end of file diff --git a/src/main/java/com/bigdata/phoenix/phoenixClient.java b/src/main/java/com/bigdata/phoenix/phoenixClient.java new file mode 100644 index 0000000..ff3724e --- /dev/null +++ b/src/main/java/com/bigdata/phoenix/phoenixClient.java @@ -0,0 +1,26 @@ +package com.bigdata.phoenix; + +import java.sql.*; +import java.util.Properties; + +public class phoenixClient { + public static void main(String[] args) throws SQLException { + // 标准的 JDBC 代码 + // 1.添加链接 + String url = "jdbc:phoenix:hadoop102,hadoop103,hadoop104:2181"; + // 2. 创建配置 + // 没有需要添加的必要配置 因为 Phoenix 没有账号密码 + Properties properties = new Properties(); + // 3. 获取连接 + Connection connection = DriverManager.getConnection(url, properties); + // 5.编译 SQL 语句 + PreparedStatement preparedStatement = connection.prepareStatement("select * from student"); + // 1.执行语句 + ResultSet resultSet = preparedStatement.executeQuery(); // 7.输出结果 + while (resultSet.next ()){ + System.out.println(resultSet.getString(2) ); + } + // 8.关闭资源 + connection.close(); + } +}