为什么我的java中的结果集将我的dbeaver列中的日期读取为null,如何解决这个问题?

问题描述 投票:0回答:1

为什么我的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;
    }
java date null resultset dbeaver
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.