Exemplo n.º 1
0
 protected void createDatabaseRecord(EncryptedData ed) throws RuntimeException {
   try (Connection conn = coreHelper.getConnection();
       PreparedStatement ps =
           conn.prepareStatement(coreHelper.getSql(conn.getMetaData(), "insert-id-path-name")); ) {
     ps.setString(1, Base64.getEncoder().encodeToString(ed.getId()));
     ps.setString(2, Base64.getEncoder().encodeToString(ed.getEncryptedPath()));
     ps.setString(3, Base64.getEncoder().encodeToString(ed.getEncryptedName()));
     if (1 != ps.executeUpdate()) {
       throw new RuntimeException("Cannot insert data");
     }
     conn.commit();
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
 }