36 |
36 |
37 /** |
37 /** |
38 * Some DAO utilities. |
38 * Some DAO utilities. |
39 */ |
39 */ |
40 public final class Functions { |
40 public final class Functions { |
|
41 |
|
42 public static String getSafeString(ResultSet rs, String column) throws SQLException { |
|
43 return Optional.ofNullable(rs.getString(column)).orElse(""); |
|
44 } |
41 |
45 |
42 public static void setStringOrNull(PreparedStatement stmt, int index, String str) throws SQLException { |
46 public static void setStringOrNull(PreparedStatement stmt, int index, String str) throws SQLException { |
43 if (str == null || str.isBlank()) { |
47 if (str == null || str.isBlank()) { |
44 stmt.setNull(index, Types.VARCHAR); |
48 stmt.setNull(index, Types.VARCHAR); |
45 } else { |
49 } else { |