當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.getBinaryStream方法代碼示例

本文整理匯總了Java中java.sql.ResultSet.getBinaryStream方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.getBinaryStream方法的具體用法?Java ResultSet.getBinaryStream怎麽用?Java ResultSet.getBinaryStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getBinaryStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fieldToFile

import java.sql.ResultSet; //導入方法依賴的package包/類
public void fieldToFile(ResultSet resultset, String s, String s1)
    throws ServletException, IOException, SmartUploadException, SQLException
{
    try
    {
        if(m_application.getRealPath(s1) != null)
            s1 = m_application.getRealPath(s1);
        InputStream inputstream = resultset.getBinaryStream(s);
        FileOutputStream fileoutputstream = new FileOutputStream(s1);
        int i;
        while((i = inputstream.read()) != -1) 
            fileoutputstream.write(i);
        fileoutputstream.close();
    }
    catch(Exception exception)
    {
        throw new SmartUploadException("Unable to save file from the DataBase (1020).");
    }
}
 
開發者ID:yuanxy,項目名稱:all-file,代碼行數:20,代碼來源:SmartUpload.java

示例2: getObjectFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * <p>
 * This method should be overridden by any delegate subclasses that need
 * special handling for BLOBs. The default implementation uses standard
 * JDBC <code>java.sql.Blob</code> operations.
 * </p>
 * 
 * @param rs
 *          the result set, already queued to the correct row
 * @param colName
 *          the column name for the BLOB
 * @return the deserialized Object from the ResultSet BLOB
 * @throws ClassNotFoundException
 *           if a class found during deserialization cannot be found
 * @throws IOException
 *           if deserialization causes an error
 */
@Override           
protected Object getObjectFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    InputStream binaryInput = rs.getBinaryStream(colName);

    if(binaryInput == null || binaryInput.available() == 0) {
        return null;
    }
    
    Object obj = null;
    
    ObjectInputStream in = new ObjectInputStream(binaryInput);
    try {
        obj = in.readObject();
    } finally {
        in.close();
    }

    return obj;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:38,代碼來源:HSQLDBDelegate.java

示例3: getObjectFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
protected Object getObjectFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    
    Object obj = null;
    InputStream binaryInput = rs.getBinaryStream(colName);
    if (binaryInput != null) {
        ObjectInputStream in = new ObjectInputStream(binaryInput);
        try {
            obj = in.readObject();
        } finally {
            in.close();
        }
    }

    return obj;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:OracleDelegate.java

示例4: readBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * Přešte blob dat ze zadaného sloupečku
 *
 * @param resultSet {@link ResultSet}
 * @param column Sloupeček, který obsahuje blob
 * @return Pole bytu
 * @throws SQLException
 * @throws IOException
 */
public static byte[] readBlob(ResultSet resultSet, String column) {
    final ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
    try {
        final InputStream binaryStream = resultSet.getBinaryStream(column);
        final byte[] buffer = new byte[1024];
        while (binaryStream.read(buffer) > 0) {
            arrayOutputStream.write(buffer);
        }
    } catch (SQLException sqlException) {
        sqlException.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return arrayOutputStream.toByteArray();
}
 
開發者ID:stechy1,項目名稱:drd,代碼行數:26,代碼來源:BaseDatabaseManager.java

示例5: getObjectFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * <p>
 * This method should be overridden by any delegate subclasses that need
 * special handling for BLOBs. The default implementation uses standard
 * JDBC <code>java.sql.Blob</code> operations.
 * </p>
 * 
 * @param rs
 *          the result set, already queued to the correct row
 * @param colName
 *          the column name for the BLOB
 * @return the deserialized Object from the ResultSet BLOB
 * @throws ClassNotFoundException
 *           if a class found during deserialization cannot be found
 * @throws IOException
 *           if deserialization causes an error
 */
protected Object getObjectFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    InputStream binaryInput = rs.getBinaryStream(colName);

    if(binaryInput == null || binaryInput.available() == 0) {
        return null;
    }

    Object obj = null;

    ObjectInputStream in = new ObjectInputStream(binaryInput);
    try {
        obj = in.readObject();
    } finally {
        in.close();
    }

    return obj;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:37,代碼來源:MSSQLDelegate.java

示例6: getVersionedList

import java.sql.ResultSet; //導入方法依賴的package包/類
private static List<Versioned<byte[]>> getVersionedList(ResultSet rs) 
            throws SQLException, JsonParseException, 
                JsonMappingException, IOException {
    InputStream is = rs.getBinaryStream("datavalue");
    return mapper.readValue(is,
                            new TypeReference<List<VCVersioned<byte[]>>>() {});
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:8,代碼來源:JavaDBStorageEngine.java

示例7: readBundle

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * Reads and parses a bundle from the BLOB in the given column of the
 * current row of the given result set. This is a helper method to
 * circumvent issues JCR-1039 and JCR-1474.
 *
 * @param id bundle identifier
 * @param rs result set
 * @param column BLOB column
 * @return parsed bundle
 * @throws SQLException if the bundle can not be read or parsed
 */
private NodePropBundle readBundle(NodeId id, ResultSet rs, int column)
        throws SQLException {
    try {
        InputStream in;
        if (rs.getMetaData().getColumnType(column) == Types.BLOB) {
            in = rs.getBlob(column).getBinaryStream();
        } else {
            in = rs.getBinaryStream(column);
        }
        try {
            return binding.readBundle(in, id);
        } finally {
            in.close();
        }
    } catch (IOException e) {
        SQLException exception =
            new SQLException("Failed to parse bundle " + id);
        exception.initCause(e);
        throw exception;
    }
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:33,代碼來源:DbPersistenceManager.java

示例8: testGetBinaryStream

import java.sql.ResultSet; //導入方法依賴的package包/類
public void testGetBinaryStream(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getBinaryStream(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:9,代碼來源:AvaticaResultSetConversionsTest.java

示例9: getBlobAsBinaryStream

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning BLOB as binary stream");
	if (this.wrapAsLob) {
		Blob blob = rs.getBlob(columnIndex);
		return blob.getBinaryStream();
	}
	else {
		return rs.getBinaryStream(columnIndex);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:DefaultLobHandler.java

示例10: getObjectFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * <p>
 * This method should be overridden by any delegate subclasses that need
 * special handling for BLOBs. The default implementation uses standard
 * JDBC <code>java.sql.Blob</code> operations.
 * </p>
 * 
 * @param rs
 *          the result set, already queued to the correct row
 * @param colName
 *          the column name for the BLOB
 * @return the deserialized Object from the ResultSet BLOB
 * @throws ClassNotFoundException
 *           if a class found during deserialization cannot be found
 * @throws IOException
 *           if deserialization causes an error
 */
@Override           
protected Object getObjectFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    InputStream binaryInput = rs.getBinaryStream(colName);

    if(binaryInput == null || binaryInput.available() == 0) {
        return null;
    }

    Object obj = null;

    ObjectInputStream in = new ObjectInputStream(binaryInput);
    try {
        obj = in.readObject();
    } finally {
        in.close();
    }

    return obj;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:38,代碼來源:MSSQLDelegate.java

示例11: getJobDataFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override           
protected Object getJobDataFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    if (canUseProperties()) {
        InputStream binaryInput = rs.getBinaryStream(colName);
        return binaryInput;
    }
    return getObjectFromBlob(rs, colName);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:MSSQLDelegate.java

示例12: getJobDataFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
protected Object getJobDataFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    
    if (canUseProperties()) {
        InputStream binaryInput = rs.getBinaryStream(colName);
        return binaryInput;
    }

    return getObjectFromBlob(rs, colName);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:OracleDelegate.java

示例13: get

import java.sql.ResultSet; //導入方法依賴的package包/類
public Object get(ResultSet rs, String name) throws HibernateException, SQLException {

		if ( Environment.useStreamsForBinary() ) {

			InputStream inputStream = rs.getBinaryStream(name);

			if (inputStream==null) return toExternalFormat( null ); // is this really necessary?

			ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
			byte[] buffer = new byte[2048];

			try {
				while (true) {
					int amountRead = inputStream.read(buffer);
					if (amountRead == -1) {
						break;
					}
					outputStream.write(buffer, 0, amountRead);
				}

				inputStream.close();
				outputStream.close();
			}
			catch (IOException ioe) {
				throw new HibernateException( "IOException occurred reading a binary value", ioe );
			}

			return toExternalFormat( outputStream.toByteArray() );

		}
		else {
			return toExternalFormat( rs.getBytes(name) );
		}
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:AbstractBynaryType.java

示例14: getJobDetailFromBlob

import java.sql.ResultSet; //導入方法依賴的package包/類
protected Object getJobDetailFromBlob(ResultSet rs, String colName)
    throws ClassNotFoundException, IOException, SQLException {
    if (canUseProperties()) {
        InputStream binaryInput = rs.getBinaryStream(colName);
        return binaryInput;
    }
    return getObjectFromBlob(rs, colName);
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:9,代碼來源:MSSQLDelegate.java

示例15: doFillWithResurltSetCol

import java.sql.ResultSet; //導入方法依賴的package包/類
public void doFillWithResurltSetCol(ResultSet resultSet, int nCol)
	throws SQLException
{
	m_is = resultSet.getBinaryStream(nCol);
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:6,代碼來源:ColValueBinaryStream.java


注:本文中的java.sql.ResultSet.getBinaryStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。