Package java.sql

Examples of java.sql.Blob


            }

            int colType = rs.getMetaData().getColumnType(1);
            switch(colType) {
                case Types.BLOB :
                    Blob blob = rs.getBlob(1);
                    if (blob != null) {
                        return new JDBCInputStream(blob.getBinaryStream(), conn);
                    }
                    break;

                case Types.CLOB :
                    Clob clob = rs.getClob(1);
View Full Code Here


    params.put("objectid", objectid);

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

    if (resultSet.next()) {
        Blob data = resultSet.getBlob("data");
      int protocolVersion = NetConst.FIRST_VERSION_WITH_MULTI_VERSION_SUPPORT - 1;
      Object temp = resultSet.getObject("protocol_version");
      if (temp != null) {
        protocolVersion = ((Integer) temp).intValue();
      }
View Full Code Here

      RPObject player = null;
      while (result.next()) {
        int objectid = result.getInt("object_id");
        String name = result.getString("charname");
        Blob data = result.getBlob("data");
        int protocolVersion = NetConst.FIRST_VERSION_WITH_MULTI_VERSION_SUPPORT - 1;
        Object temp = result.getObject("protocol_version");
        if (temp != null) {
          protocolVersion = ((Integer) temp).intValue();
        }
View Full Code Here

    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

   
    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

    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

     *
     * @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

        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

                }

                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

        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

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.