Noticias Weblogs Foros Wiki Código

RecorteX

458 usuarios y 235 recortes de código
Usuario

Contraseña
Crear cuenta
asp csharp css fechas Flash html imagenes java javascript linux mysql oracle php sql SQLServer url vbnet web xhtml xml
Top Usuarios
fjmp76 (35)
albin (31)
josuebasurto (31)
juanjo (29)
pedrocaro (9)
stanz (8)
AndiXTRM (7)
Joserra (7)
miiglesi (6)
aplyca (5)
Top Etiquetas
php (38)
vbnet (27)
javascript (26)
html (25)
java (23)
csharp (18)
sql (17)
mysql (13)
xml (13)
css (10)
Flash (7)
imagenes (7)
xhtml (7)
asp (6)
linux (6)
fechas (6)
SQLServer (5)
oracle (5)
url (5)
web (5)

Leer un String de un Blob

Método para leer un String que por necesidades de tamaño se introduce en un blob. Al método se le pasa el resultSet y el nombre del campo en el que se encuentra el blob.
 
 
    public String leerBlob(ResultSet rs,String blob){
        String returndata="";
        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
        BufferedInputStream bis;
        try {
            bis = new BufferedInputStream(rs.getBinaryStream(blob));
            byte[] bindata=new byte[1024];
            int bytesread = 0;
            try {
                if ( !rs.wasNull() ) {
                    if ( (bytesread = bis.read(bindata,0,bindata.length)) != -1 ) {
                        baos.write(bindata,0,bytesread);
                        returndata= baos.toString();
                    }
                    bis.close();
                }
            } catch (IOException e) {
                System.out.println("leerBlob -- Se produjo un error en la consulta");
                System.out.println(e.getMessage());
            }
        } catch (SQLException ex) {
            System.out.println("leerBlob -- Se produjo un error en la consulta");
            System.out.println(ex.getMessage());
        }
        return returndata;
    }
 
Identifícate para dejar un comentario.
info@recortex.com - Proyecto: Juanjo Navarro, 2006 - Diseño: Albin - Información legal y técnica