为什么我的Java结果集读取我的DBeaver列中的日期为null以及如何解决这个问题?在下面的照片中,您可以看到Java不在这种情况下从DBeaver中读取我的date列为null,以及在Java中准备好的语句和结果集。
Java console - can see that Java is reading my date column as null when it is not
DBeaver - can see that my date column is not null
public Set<Reimbursement> getReimbursementsForEmployee(Employee employee) {
Connection conn = ConnectionUtil.getConnection();
String sql = "SELECT * FROM reimbursement WHERE e_id = ?";
Set<Reimbursement> reimbursements = new HashSet<Reimbursement>();
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, employee.getEmployeeId());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Reimbursement reimbursement = new Reimbursement();
reimbursement.setReimbursementNumber(rs.getInt("reimbursementnumber"));
reimbursement.setDate(rs.getDate("ddate"));
reimbursement.setAmount(rs.getDouble("amount"));
reimbursement.setReimbursementRequestInfo(rs.getString("reimbursementrequestinfo"));
reimbursement.setManagerComment(rs.getString("managercomment"));
reimbursement.setStatus(rs.getString("status"));
reimbursement.setEmployeeId(rs.getInt("e_id"));
reimbursement.setManagerId(rs.getInt("m_id"));
reimbursements.add(reimbursement);
}
return reimbursements;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}