2024.3.11

周一,一周的开始.

 /**
* function: 打卡
*/


// 在方法中获取当前系统日期并插入数据库
public static String daka(String time_s, String time_e, String text) {
int text1 = Integer.parseInt(text);
StringBuilder resultBuilder = new StringBuilder();
Connection connection = JDBCUtils.getConn();
try {
if (connection != null) {
System.out.println("11234");
}
if (connection != null) {
String sql1 = "SELECT * FROM room WHERE MeetroomId = ? AND Capacity <= ?";
PreparedStatement ps1 = connection.prepareStatement(sql1);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = dateFormat.format(new Date());
ps1.setString(1, time_s);
// ps1.setString(3, time_e);
ps1.setInt(2, text1);
ResultSet resultSet = ps1.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 text2 = 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");
}

} else {
return "0"; // 连接数据库失败,返回"0"
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("发生异常:" + e.getMessage()); // 输出异常信息
return "0"; // 发生异常,返回"0"
} finally {
// 可以在这里关闭连接等资源
}
return resultBuilder.toString();
}
posted @ 2024-03-12 22:33  kxzzow  阅读(21)  评论(0)    收藏  举报