get From Blob - Java java.sql

Java examples for java.sql:Blob

Description

get From Blob

Demo Code


//package com.java2s;
import java.sql.Blob;
import java.sql.SQLException;

public class Main {
    static public String getFromBlob(Blob blob) {
        String result = null;/*from w  w  w .  j  a  v  a2s  .c  o m*/
        byte[] bdata;

        try {
            if (blob != null) {
                bdata = blob.getBytes(1, (int) blob.length());
                result = new String(bdata);
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace(System.out);
        }
        return result;
    }
}

Related Tutorials