From 67a270aeaf8f8f9e3639ce1431c222ff0206f9cb Mon Sep 17 00:00:00 2001 From: fly6516 Date: Wed, 26 Mar 2025 09:55:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=BB=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=85=A5=E5=8F=A3=E5=8F=8A=E5=9F=BA=E6=9C=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=BC=94=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 EmpHBaseClient 类中添加 main 方法作为程序入口 - 实现了创建表结构、加载 CSV 数据、查询特定条件的员工信息等功能的演示- 添加了 finally 块以确保客户端正确关闭 --- src/main/java/EmpHBaseClient.java | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/EmpHBaseClient.java b/src/main/java/EmpHBaseClient.java index 2487c71..bc4ca7d 100644 --- a/src/main/java/EmpHBaseClient.java +++ b/src/main/java/EmpHBaseClient.java @@ -238,4 +238,40 @@ public class EmpHBaseClient { return date; } } + + // 新增main方法作为入口 + public static void main(String[] args) { + EmpHBaseClient client = null; + try { + client = new EmpHBaseClient(); + System.out.println("1. 创建表结构..."); + client.createEmpTable(); + + System.out.println("2. 加载CSV数据..."); + client.loadEmployeesFromCSV("emp.txt"); + + System.out.println("\n3. 查询ID≥7500的员工:"); + client.findEmployeesWithEmpnoAbove7500(); + + System.out.println("\n4. 查询绩效>4且入职早于2022的员工:"); + client.findQualifiedEmployees(); + + System.out.println("\n5. 最近晋升记录:"); + client.findLatestPromotion(); + + System.out.println("\n6. 培训课程统计:"); + client.countTrainingCourses(); + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (client != null) { + try { + client.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } } \ No newline at end of file