in signature/src/main/java/com/chemistry/enotebook/signature/database/DatabaseConnector.java [271:318]
private Set<Map> execute(String sql, Object...parameters) {
Connection con = null;
PreparedStatement prepStmt = null;
ResultSet rs = null;
try {
con = dataSource.getConnection();
prepStmt = con.prepareStatement(sql);
for (int i = 0; i < parameters.length; i++) {
Object obj = parameters[i];
if (obj instanceof UUID || obj instanceof Boolean) {
obj = obj.toString();
}
prepStmt.setObject(i + 1, obj);
}
if(sql.toLowerCase().contains("select")) {
rs = prepStmt.executeQuery();
return resultSetToHashSet(rs);
} else {
prepStmt.executeUpdate();
return null;
}
} catch (Exception e) {
log.warn("Error executing SQL query: " + e.getMessage());
throw new IndigoSignatureServiceException(e);
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (Exception ignored) {
}
try {
if (prepStmt != null) {
prepStmt.close();
}
} catch (Exception ignored) {
}
try {
if (con != null) {
con.close();
}
} catch (Exception ignored) {
}
}
}