Java SQL Blob blobToBytes(Blob blob)

Here you can find the source of blobToBytes(Blob blob)

Description

blob to byte array

License

Apache License

Parameter

Parameter Description
blob java.sql.Blob

Return

byte[]

Declaration

public static byte[] blobToBytes(Blob blob) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Blob;

import java.sql.SQLException;

public class Main {
    /**//w ww.j  a va 2 s . c  o m
     * blob to byte array
     * @param blob java.sql.Blob
     * @return byte[]
     */
    public static byte[] blobToBytes(Blob blob) {
        byte[] bytes = null;
        if (blob == null)
            return bytes;

        try {
            bytes = blob.getBytes(1, (int) blob.length());
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return bytes;
    }
}

Related

  1. blob2FloatArray(Blob blob)
  2. blobToBytes(Blob blob)
  3. getAsString(Blob blob)
  4. getBlobType(byte[] image)
  5. getDataFromBlob(Blob b)