Created
July 10, 2017 16:54
-
-
Save khaosans/7ebd10a7a38ae2e6546bf92ab27ce9f7 to your computer and use it in GitHub Desktop.
verified income
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean updateIncome(VerifiedIncomeAttributes attributes) { | |
try { | |
queryRunner.update("UPDATE verifiedincome " + | |
"SET uuid= ? , loanid = ?, income = ?, schedulec = ?, schedulee = ?, schedulek1 = ? " + | |
"WHERE ownerid = ? and year = ?", UUID.randomUUID(), attributes.getLoanId(), attributes.getIncome(), | |
attributes.getScheduleC(), attributes.getScheduleE(), attributes.getScheduleK1(), | |
attributes.getOwnerId(), attributes.getYear()); | |
} catch (SQLException e) { | |
throw new RuntimeException("Error updating income", e); | |
} | |
return true; | |
} | |
@Override | |
public boolean incomeExists(long owner, long year) { | |
long numberOfRecords; | |
try ( | |
Connection conn = dataSource.getConnection(); | |
PreparedStatement stmt = conn.prepareStatement("select count(*) from verifiedincome where ownerid = ? and year = ?;", Statement.RETURN_GENERATED_KEYS) | |
) { | |
stmt.setObject(1, owner); | |
stmt.setLong(2, year); | |
stmt.execute(); | |
try (ResultSet rs = stmt.getGeneratedKeys()) { | |
if (rs.next()) { | |
numberOfRecords = rs.getInt(1); | |
} | |
else { | |
throw new RuntimeException("better message"); | |
} | |
} | |
} | |
catch (SQLException e) { | |
throw new RuntimeException("better message", e); | |
} | |
return numberOfRecords >0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment