当前位置: 首页>>代码示例>>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;未经允许,请勿转载。