Java SQL Blob safeFree(Blob blob)

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

Description

safe Free

License

Apache License

Declaration

public static final void safeFree(Blob blob) 

Method Source Code


//package com.java2s;
/*                                                                         
 * Copyright 2010-2013 the original author or authors.                     
 *                                                                         
 * Licensed under the Apache License, Version 2.0 (the "License");         
 * you may not use this file except in compliance with the License.        
 * You may obtain a copy of the License at                                 
 *                                                                         
 *      http://www.apache.org/licenses/LICENSE-2.0                         
 *                                                                         
 * Unless required by applicable law or agreed to in writing, software     
 * distributed under the License is distributed on an "AS IS" BASIS,       
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and     
 * limitations under the License.                                          
 *///from w  ww  .ja  v a  2s .  c o m

import java.sql.Array;
import java.sql.Blob;

import java.sql.Clob;

import java.sql.SQLXML;

public class Main {
    public static final void safeFree(Blob blob) {
        if (blob != null) {
            try {
                blob.free();
            } catch (Exception ignore) {
            }
            // [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
            catch (AbstractMethodError ignore) {
            }
        }
    }

    public static final void safeFree(Clob clob) {
        if (clob != null) {
            try {
                clob.free();
            } catch (Exception ignore) {
            }
            // [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
            catch (AbstractMethodError ignore) {
            }
        }
    }

    public static final void safeFree(SQLXML xml) {
        if (xml != null) {
            try {
                xml.free();
            } catch (Exception ignore) {
            }
            // [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
            catch (AbstractMethodError ignore) {
            }
        }
    }

    public static final void safeFree(Array array) {
        if (array != null) {
            try {
                array.free();
            } catch (Exception ignore) {
            }
            // [#3069] The free() method was added only in JDBC 4.0 / Java 1.6
            catch (AbstractMethodError ignore) {
            }
        }
    }
}

Related

  1. getString(Blob blob)
  2. getStringValue(Blob blob)
  3. isBlob(Object object)
  4. readBlob(Blob blob)
  5. readBytes(Blob blob, byte[] defaultValue)
  6. safeFree(Blob blob)
  7. toByteArray(Blob blob)
  8. writeStringToBlob(String value, PreparedStatement preparedStatement, int index)
  9. writeToBlob(int index, PreparedStatement ps, byte[] data)