Examples of Blob


Examples of java.sql.Blob

    logger.debug("loadRPZone is executing query " + query);

    ResultSet resultSet = transaction.query(query, params);

    if (resultSet.next()) {
      Blob data = resultSet.getBlob("data");
      InputStream input = data.getBinaryStream();
      ByteArrayOutputStream output = new ByteArrayOutputStream();

      // set read buffer size
      byte[] rb = new byte[1024];
      int ch = 0;
View Full Code Here

Examples of java.sql.Blob

   
    int columnType = resultSet.getMetaData().getColumnType(columnIndex.intValue());
    switch (columnType)
    {
      case Types.BLOB:
        Blob blob = resultSet.getBlob(columnIndex.intValue());
        if (!resultSet.wasNull())
        {
          is = blob.getBinaryStream();
          size = blob.length();
        }
        break;
       
      default:
        is = resultSet.getBinaryStream(columnIndex.intValue());
View Full Code Here

Examples of java.sql.Blob

    public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
        if (isBlob) {
            if (value == null)
                Hibernate.BLOB.nullSafeSet(st, value, index, session);
            else {
                Blob blob = Hibernate.createBlob((byte[])value);
                Hibernate.BLOB.nullSafeSet(st, blob, index, session);
            }
        } else {
            Hibernate.BINARY.nullSafeSet(st, value, index, session);
        }
View Full Code Here

Examples of java.sql.Blob

     *
     * @throws java.sql.SQLException
     */
    public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
        if (isBlob) {
            Blob blob = (Blob)Hibernate.BLOB.nullSafeGet(rs, names, session, owner);
            if (blob == null)
                return null;
            else
                return copyData(blob.getBinaryStream());
        } else {
            return Hibernate.BINARY.nullSafeGet(rs, names, session, owner);
        }
    }
View Full Code Here

Examples of java.sql.Blob

        ByteArrayOutputStream out = null;
        BufferedInputStream in = null;
        ResultSet rs = null;
        Statement stmt = null;
        byte[] result = {};
        Blob blob;
        int bytesRead;

        try {
            logger.debug9("calling " + SOSClassUtil.getMethodName());

            if (connection == null)
                    throw new Exception(
                            SOSClassUtil.getMethodName()
                                    + ": sorry, there is no successful connection established."
                                    + " may be the connect method was not called");

            query = normalizeStatement(query, replacement);
            if (profiler != null) try {
                profiler.start(query);
            } catch (Exception e) {
            }

            stmt = connection.createStatement();
            logger.debug6(".. " + query);
            rs = stmt.executeQuery(query);

            if (rs.next()) {
                blob = rs.getBlob(1);

                if (blob == null) {
                    logger.debug9(".. ResultSet returns NULL value.");
                    return result;
                }
                byte[] data = new byte[(int) blob.length()];
                out = new ByteArrayOutputStream((int) blob.length());
                in = new BufferedInputStream(blob.getBinaryStream());
                if (in == null) {
                    logger
                            .debug9(".. ResultSet InputStream returns NULL value.");
                    return result;
                }
View Full Code Here

Examples of java.sql.Blob

                }

                break;
            }
            case Types.SQL_BLOB : {
                Blob blob = getBlob(columnIndex);

                if (blob == null) {
                    sqlxml = null;
                } else {
                    sqlxml = new JDBCSQLXML(blob.getBinaryStream());
                }

                break;
            }
            case Types.SQL_BINARY :
            case Types.SQL_VARBINARY : {
                java.io.InputStream inputStream = getBinaryStream(columnIndex);

                if (inputStream == null) {
                    sqlxml = null;
                } else {
                    sqlxml = new JDBCSQLXML(inputStream);
                }

                break;
            }
            case Types.OTHER :
            case Types.JAVA_OBJECT : {
                Object data = getObject(columnIndex);

                if (data == null) {
                    sqlxml = null;
                } else if (data instanceof SQLXML) {
                    sqlxml = (SQLXML) data;
                } else if (data instanceof String) {
                    sqlxml = new JDBCSQLXML((String) data);
                } else if (data instanceof byte[]) {
                    sqlxml = new JDBCSQLXML((byte[]) data);
                } else if (data instanceof Blob) {
                    Blob blob = (Blob) data;

                    sqlxml = new JDBCSQLXML(blob.getBinaryStream());
                } else if (data instanceof Clob) {
                    Clob clob = (Clob) data;

                    sqlxml = new JDBCSQLXML(clob.getCharacterStream());
                } else {
View Full Code Here

Examples of java.sql.Blob

        catch (SQLException sqle)
        {
            try
            {
                // Retrieve the bytes using the Blob (if getBytes not supported e.g HSQLDB 2.0)
                Blob blob = ((ResultSet)rs).getBlob(param);
                if (blob == null)
                {
                    return null;
                }
                bytes = blob.getBytes(1, (int)blob.length());
                if (bytes == null)
                {
                    return null;
                }
            }
View Full Code Here

Examples of java.sql.Blob

    {
        Object obj = null;

        try
        {
            Blob blob = ((ResultSet)rs).getBlob(param);
            if (!((ResultSet)rs).wasNull())
            {
                byte[] bytes = blob.getBytes(1,(int)blob.length());
                if (bytes.length < 1)
                {
                    return null;
                }
                try
View Full Code Here

Examples of java.sql.Blob

        // render!
        switch (columnType) {

        case Types.BLOB:
            Blob blob = resultSet.getBlob(columnIndex);
            if (blob == null) {
                throw new Exception("BLOB value is null.");
            }
            streamBytes(blob.getBinaryStream(), response);
            break;

        case Types.CLOB:
            Clob clob = resultSet.getClob(columnIndex);
            if (clob == null) {
View Full Code Here

Examples of java.sql.Blob

            if (this.updateQueryDefinition == null) {

                // in-place modification
                // Get a reference to the blob
                Blob blob = resultSet.getBlob(columnIndex);
                if (blob == null) {
                    throw new Exception("BLOB value is null.");
                }

                // clear the BLOB. If we don't do this, previous data in the
                // BLOB that exceeds the length of the new data will not be
                // overwritten.
                // FIXME Not supported by MySQL
                // blob.truncate(0);

                // copy the request body to the BLOB
                writeBytes(request.getInputStream(), blob.setBinaryStream(1));

            } else {

                // use the update query (this is the most common situation:
                // MySQL, Oracle)
                Query updateQuery = new Query(this.updateQueryDefinition,
                        parameterResolver);

                // The blob object should be already in the parameters via the
                // BlobColumnDomain
                Blob blob = getBlob(updateQuery.getStatementParameters());
                if (blob == null) {
                    throw new Exception("Unable to get reference to a BLOB. "
                            + "Maybe the BLOB field is null on the db "
                            + "or the wrong column name has been specified.");
                }

                // clear the BLOB. If we don't do this, previous data in the
                // BLOB that exceeds the length of the new data will not be
                // overwritten.
                // FIXME Not supported by MySQL
                // blob.truncate(0);

                // write the request body to the blob
                writeBytes(request.getInputStream(), blob.setBinaryStream(1));
                // perform the update
                updateQuery.execute(connection);

            }
            break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.