code: private static byte[] blobToBytes(Blob blob) {
          try (InputStream is = blob.getBinaryStream()) {
              byte[] b = new byte[(int) blob.length()];
              if (is.read(b) != -1) {
                  return b;
              } else {
                  return new byte[0];
              }
          } catch (IOException | SQLException e) {
              logger.error(e.getMessage());
              return null;
          }
      }
docs: Blob转byte[]