oracle.sql.BLOB类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中oracle.sql.BLOB类的一些代码示例,展示了BLOB类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BLOB类的具体详情如下:
包路径:oracle.sql.BLOB
类名称:BLOB

BLOB介绍

[英]Mock class providing the declarations required to compile the Cocoon code when the actual library is not present.
[中]当实际库不存在时,模拟类提供编译Cocoon代码所需的声明。

代码示例

代码示例来源:origin: quartz-scheduler/quartz

@SuppressWarnings("deprecation")
  protected Blob writeDataToBlob(ResultSet rs, int column, byte[] data) throws SQLException {

    Blob blob = rs.getBlob(column); // get blob

    if (blob == null) { 
      throw new SQLException("Driver's Blob representation is null!");
    }
    
    if (blob instanceof oracle.sql.BLOB) { // is it an oracle blob?
      ((oracle.sql.BLOB) blob).putBytes(1, data);
      ((oracle.sql.BLOB) blob).trim(data.length);
      return blob;
    } else {
      throw new SQLException(
          "Driver's Blob representation is of an unsupported type: "
              + blob.getClass().getName());
    }
  }
}

代码示例来源:origin: stackoverflow.com

rset.next();
Blob bobj = rset.getBlob(1);
BLOB object = (BLOB) bobj;
int chunkSize = object.getChunkSize();
byte[] binaryBuffer = new byte[chunkSize];
int position = 1;
int bytesRead = 0;
int bytesWritten = 0, totbytesRead = 0, totbytesWritten = 0;
InputStream is = fileItem.getInputStream();
while ((bytesRead = is.read(binaryBuffer)) != -1) {
bytesWritten = object.putBytes(position, binaryBuffer, bytesRead);
position += bytesRead;
totbytesRead += bytesRead;
totbytesWritten += bytesWritten;
is.close();

代码示例来源:origin: stackoverflow.com

int primaryKeyId = getNextPrimaryKeyId();
PreparedStatement stmt1 = conn.prepareStatement(" insert into docTable values (?, ?, empty_blob()) ");
stmt1.setInt(1, primaryKeyId );
stmt1.setString(2, getDocumentTitle());
stmt1.executeUpdate();

PreparedStatement stmt2 = conn.prepareStatement(" select doc from docTable where id = ? for update ");
stmt2.setInt(1, primaryKeyId);
stmt2.execute();

OracleResultSet rset = (OracleResultSet)stmt2.getResultSet();
if (rset.next()) {
 BLOB document = rset.getBLOB("doc");
 document.trim(0);
 OutputStream os = document.getBinaryOutputStream();
 os.write(getDocumentToBeWrittenToDb());
 os.flush;
 os.close;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Write LOB value - only on Oracle8 and up
 */
@SuppressWarnings("deprecation")
public void writeLOB(DatabaseField field, Object value, ResultSet resultSet, AbstractSession session) throws SQLException {
  if (isBlob(field.getType())) {
    //change for 338585 to use getName instead of getNameDelimited
    oracle.sql.BLOB blob = (oracle.sql.BLOB)resultSet.getObject(field.getName());
    //we could use the jdk 1.4 java.nio package and use channel/buffer for the writing 
    //for the time being, simply use Oracle api.
    blob.putBytes(1, (byte[])value);
    //impose the locallization
    session.log(SessionLog.FINEST, SessionLog.SQL, "write_BLOB", Long.valueOf(blob.length()), field.getName());
  } else if (isClob(field.getType())) {
    //change for 338585 to use getName instead of getNameDelimited
    oracle.sql.CLOB clob = (oracle.sql.CLOB)resultSet.getObject(field.getName());
    //we could use the jdk 1.4 java.nio package and use channel/buffer for the writing
    //for the time being, simply use Oracle api.
    clob.putString(1, (String)value);
    //impose the locallization
    session.log(SessionLog.FINEST, SessionLog.SQL, "write_CLOB", Long.valueOf(clob.length()), field.getName());
  } else {
    //do nothing for now, open to BFILE or NCLOB types
  }
}

代码示例来源:origin: com.bbossgroups/bboss-persistent

outstream = blob.getBinaryOutputStream();
int bufferSize = blob.getChunkSize();
byte[] buffer = new byte[bufferSize];

代码示例来源:origin: jpox/jpox

if (blob != null)
  blob.putBytes(1, bytes);

代码示例来源:origin: com.bbossgroups/bboss-persistent

/**
 * Returns the bytes from a result set
 * 
 * @param res
 *            The ResultSet to read from
 * @param columnName
 *            The name of the column to read from
 * 
 * @return The byte value from the column
 */
public byte[] getBytesFromResultset(ResultSet res, String columnName)
    throws SQLException {
  // read the bytes from an oracle blob
  oracle.sql.BLOB blob = ((OracleResultSet) res).getBLOB(columnName);
  byte[] content = new byte[(int) blob.length()];
  content = blob.getBytes(1, (int) blob.length());
  return content;
}

代码示例来源:origin: com.google.code.plsqlgateway/plsqlgateway-core

public byte[] get() {
  if (!isFormField)
   return blob.getBytes();
  else
   return bos.toByteArray();
}

代码示例来源:origin: org.opencms/opencms-solr

/**
 * Generates an Output stream that writes to a blob, also truncating the existing blob if required.<p>
 * 
 * Apparently Oracle requires some non-standard handling here.<p>
 * 
 * @param res the result set where the blob is located in 
 * @param name the name of the database column where the blob is located
 * @return an Output stream from a blob
 * @throws SQLException if something goes wring
 */
public static OutputStream getOutputStreamFromBlob(ResultSet res, String name) throws SQLException {
  // TODO: perform blob check only once and store Oracle version in a static private member 
  // TODO: best do this during system startup / db init phase once
  Blob blob = res.getBlob(name);
  try {
    // jdbc standard
    blob.truncate(0);
    return blob.setBinaryStream(0L);
  } catch (SQLException e) {
    // oracle 9 & 8 (if using the same jdbc driver as provided by oracle9: ojdbc14.jar)
    ((oracle.sql.BLOB)blob).trim(0);
    return ((oracle.sql.BLOB)blob).getBinaryOutputStream();
  }
}

代码示例来源:origin: com.bbossgroups/bboss-persistent

outstream = blob.getBinaryOutputStream();
instream = new java.io.BufferedInputStream(new java.io.FileInputStream(file));
int bufferSize = blob.getChunkSize();
byte[] buffer = new byte[bufferSize];

代码示例来源:origin: org.datanucleus/datanucleus-rdbms

blob.putBytes(1, bytes); // Deprecated but what can you do

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

BLOB blob = (BLOB)((OracleResultSet) rs).getBlob(1);
int len = (int) blob.length();
data = blob.getBytes(1,len);
if (DBParms.getDriverLogging()) {
    if (data.length == 0) {

代码示例来源:origin: com.google.code.plsqlgateway/plsqlgateway-core

public String getString(String charset) {
  String value;
  try {
      if (!isFormField)
        value= new String(blob.getBytes(),charset);
      else
        value= new String(bos.toByteArray(), charset);
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
  logger.debug(fieldName+": "+value);
  return value;
}

代码示例来源:origin: quartz-scheduler/quartz

@SuppressWarnings("deprecation")
  protected Blob writeDataToBlob(ResultSet rs, int column, byte[] data) throws SQLException {

    Blob blob = rs.getBlob(column); // get blob

    if (blob == null) { 
      throw new SQLException("Driver's Blob representation is null!");
    }
    
    if (blob instanceof oracle.sql.BLOB) { // is it an oracle blob?
      ((oracle.sql.BLOB) blob).putBytes(1, data);
      ((oracle.sql.BLOB) blob).trim(data.length);
      return blob;
    } else {
      throw new SQLException(
          "Driver's Blob representation is of an unsupported type: "
              + blob.getClass().getName());
    }
  }
}

代码示例来源:origin: com.bbossgroups/bboss-persistent

outstream = blob.getBinaryOutputStream();
int bufferSize = blob.getChunkSize();
byte[] buffer = new byte[bufferSize];

代码示例来源:origin: org.quartz-scheduler/quartz-oracle

@SuppressWarnings("deprecation")
  protected Blob writeDataToBlob(ResultSet rs, int column, byte[] data) throws SQLException {

    Blob blob = rs.getBlob(column); // get blob

    if (blob == null) { 
      throw new SQLException("Driver's Blob representation is null!");
    }
    
    if (blob instanceof oracle.sql.BLOB) { // is it an oracle blob?
      ((oracle.sql.BLOB) blob).putBytes(1, data);
      ((oracle.sql.BLOB) blob).trim(data.length);
      return blob;
    } else {
      throw new SQLException(
          "Driver's Blob representation is of an unsupported type: "
              + blob.getClass().getName());
    }
  }
}

代码示例来源:origin: com.bbossgroups/bboss-persistent

outstream = blob.getBinaryOutputStream();
int bufferSize = blob.getChunkSize();
byte[] buffer = new byte[bufferSize];

相关文章