5.15

周三

/**
* function: 打卡记录
*/

public static String records(String account) throws SQLException {
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
StringBuilder resultBuilder = new StringBuilder();

try {
connection = JDBCUtils.getConn();
String sql = "SELECT * FROM room";
statement = connection.prepareStatement(sql);


resultSet = statement.executeQuery();

while (resultSet.next()) {
String date = resultSet.getString("MeetroomId");
String resultAccount = resultSet.getString("MeetroomName");
String times = resultSet.getString("Address");
String timee = resultSet.getString("ReadyState");
String text = resultSet.getString("Capacity");

// 将查询结果拼接为字符串
resultBuilder.append("会议室编号:").append(date).append("\n").append("会议室名称: ").append(resultAccount).append("\n")
.append("会议室地址: ").append(times).append("\n")
.append("可用状态: ").append(timee).append("\n")
.append("容纳人数: ").append(text).append("\n\n");
}

} catch (SQLException e) {
e.printStackTrace();
}

return resultBuilder.toString();
}
posted @   yblll  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示