I am able to make a connection to my database but unable to execute a SET query properly. From looking at the documentation, I should be using execute not executeQuery or executeUpdate. I have a working connection and this is the rest :
try (Statement st = connection.createStatement()) {
boolean result = st.execute("SET search_path TO '712275-8S8DH-74DASS'");
ResultSet queryResult = st.executeQuery("SELECT MAX(customer.last_updated) from customer");
while (queryResult.next()) {
String lastUpdated = queryResult.getString("last_updated");
}
} catch (SQLException ex) {
LOGGER.info(ex.getMessage());
}
I get these exceptions: The column name last_updated was not found in this ResultSet. and No data from query which makes me think the search_path hasn't been set properly because when I make a direct connection using psql, I am able to get results by running
postgres=> SET search_path TO '712275-8S8DH-74DASS';
SET
postgres=> SELECT MAX(customer.last_updated) from customer;
[expected result]
[expected result]does not show the column name aslast_updatedgetObject(..., LocalDateTime.class)to begin with - don't retrieve timestamps as strings