feat: 添加主程序入口及基本功能演示
- 在 EmpHBaseClient 类中添加 main 方法作为程序入口 - 实现了创建表结构、加载 CSV 数据、查询特定条件的员工信息等功能的演示- 添加了 finally 块以确保客户端正确关闭
This commit is contained in:
parent
e6ac32b6f2
commit
67a270aeaf
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user