Package java.sql

Examples of java.sql.Blob


        if (useGetBytesForBlobs)
            return rs.getBytes(column);
        if (useGetObjectForBlobs)
            return (byte[]) rs.getObject(column);

        Blob blob = getBlob(rs, column);
        if (blob == null)
            return null;
        int length = (int) blob.length();
        if (length == 0)
            return null;
        return blob.getBytes(1, length);
    }
View Full Code Here


                }
            } else if (columnValue instanceof Clob && parameterType == String.class) {
                Clob clob = (Clob) columnValue;
                columnValue = IOUtils.toString(clob.getAsciiStream());
            } else if (columnValue instanceof Blob && parameterType == byte[].class) {
                Blob blob = (Blob) columnValue;
                columnValue = IOUtils.toByteArray(blob.getBinaryStream());
            } else if (columnValue instanceof Blob && parameterType == InputStream.class) {
                Blob blob = (Blob) columnValue;
                columnValue = blob.getBinaryStream();
            }
            setter.invoke(obj, columnValue);
        } catch (Throwable ex) {
            throw new LumifyException("Could not call setter " + setter + " on obj " + obj + " with value " + columnValue + " (" + (columnValue == null ? "null" : columnValue.getClass().getName()) + ")", ex);
        }
View Full Code Here

        // At this point we don't have any idea if the DB2 column was defined as
        //     a blob or if it was defined as CHAR for BIT DATA.
        // First try as a blob, if that doesn't work, then try as CHAR for BIT DATA
        // If that doesn't work, then go ahead and throw the first exception
        try {
            Blob blob = getBlob(rs, column);
            if (blob == null) {
                return null;
            }
           
            int length = (int) blob.length();
            if (length == 0) {
                return null;
            }
           
            return blob.getBytes(1, length);
        }
        catch (SQLException e) {
            try {
                return rs.getBytes(column);
            }
View Full Code Here

        if (useGetBytesForBlobs || useGetObjectForBlobs) {
            byte[] bytes = getBytes(rs, column);
            if (bytes != null && bytes.length > 0)
                in = new ByteArrayInputStream(bytes);
        } else {
            Blob blob = getBlob(rs, column);
            if (blob != null && blob.length() > 0)
                in = blob.getBinaryStream();
        }
        if (in == null)
            return null;

        try {
View Full Code Here

        if (useGetBytesForBlobs)
            return rs.getBytes(column);
        if (useGetObjectForBlobs)
            return (byte[]) rs.getObject(column);

        Blob blob = getBlob(rs, column);
        if (blob == null)
            return null;
        int length = (int) blob.length();
        if (length == 0)
            return null;
        return blob.getBytes(1, length);
    }
View Full Code Here

                    for (int i = 0; i < columns; i++) {
                        if (meta.getColumnType(i + 1) == Types.CLOB)
                            row.add(rs.getString(i + 1));
                        else if (meta.getColumnType(i + 1) == Types.LONGVARBINARY
                                || meta.getColumnType(i + 1) == Types.BLOB) {
                            Blob blob = rs.getBlob(i + 1);
                            Object o;
                            if (blob == null)
                                o = null;
                            else
                                o = SerializationHelper.readObjectInContext(blob.getBinaryStream());
                            row.add(serializedDataMsg + "(" + o + ")");
                        }
                        else
                            row.add(rs.getObject(i + 1));
                    }
View Full Code Here

    class ViewRowMapper implements RowMapper<GraphicalView> {
        @Override
        public GraphicalView mapRow(ResultSet rs, int rowNum) throws SQLException {
            GraphicalView v;
            Blob blob = rs.getBlob(1);
            if (blob == null)
                // This can happen during upgrade
                v = new GraphicalView();
            else
                v = (GraphicalView) SerializationHelper.readObjectInContext(blob.getBinaryStream());

            v.setId(rs.getInt(2));
            v.setXid(rs.getString(3));
            v.setName(rs.getString(4));
            v.setBackgroundFilename(rs.getString(5));
View Full Code Here

            stmt.setString(1, sid.getValue());
            ResultSet res = stmt.executeQuery();
            while (res.next()) {
                BigInteger mn = res.getBigDecimal(1).toBigInteger();
                String to = res.getString(2);
                Blob blob = res.getBlob(3);
                byte[] bytes = blob.getBytes(1, (int)blob.length());    
                RMMessage msg = new RMMessage();
                msg.setMessageNumber(mn);
                msg.setTo(to);
                msg.setContent(bytes);
                msgs.add(msg);               
View Full Code Here

          st.setBytes(valueIndex, bytes);
        } else if (value instanceof InputStream) {
          InputStream inputStream = (InputStream) value;
          st.setBinaryStream(valueIndex, inputStream);
        } else if (value instanceof Blob) {
          Blob blob = (Blob) value;
          st.setBlob(valueIndex, blob);
        } else {
          st.setObject(valueIndex, value);
        }
      } else if (type.isLiteral()) {
View Full Code Here

        if (useGetBytesForBlobs || useGetObjectForBlobs) {
            byte[] bytes = getBytes(rs, column);
            if (bytes != null && bytes.length > 0)
                in = new ByteArrayInputStream(bytes);
        } else {
            Blob blob = getBlob(rs, column);
            if (blob != null && blob.length() > 0)
                in = blob.getBinaryStream();
        }
        if (in == null)
            return null;

        try {
View Full Code Here

TOP

Related Classes of java.sql.Blob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.