Hi All,
This is a page I coded to put a byte stream and read byte stream using blob
field.
Though it did not give any error it is not function.
While reading it does not read the blob field properly.
I do also know whether it has been inserted into the table.
Can somebody help me !!!

============================================================================
======
<%@ page import="java.sql.*,DBConnect.*,oracle.sql.*" %>
<jsp:useBean id="dbConnBean" class="DBConnect.DBConnectBean" scope="page"/>

<%
Connection jdbcConn;
Statement stmt;
ResultSet rs;
oracle.sql.BLOB myblob;
try {
 jdbcConn = dbConnBean.makeConnection();
 stmt = jdbcConn.createStatement();

 //Writing data into a blob field
 byte[] data = {0,1,2,3,4,5,6,7};
 rs = stmt.executeQuery("select blob_col from lob_table");
 if(rs.next()) {
  myblob = (BLOB)rs.getObject("blob_col");
  java.io.OutputStream outstream = ((BLOB)myblob).getBinaryOutputStream();
  outstream.write(data);
  out.println("Data written successfully<br>");
  for(int i = 0;i < data.length;i++) {
   out.println(data[i]+"<br>");
  }
 }
 rs.close();

 //Reading data from a blob field
 byte[] mydata = new byte[10];
 rs = stmt.executeQuery("select blob_col from lob_table");
 if(rs.next()) {
  myblob = (BLOB)rs.getObject("blob_col");
  java.io.InputStream instream = myblob.getBinaryStream();
  int bytes_read = instream.read(mydata);
  out.println(bytes_read+"Data read successfully<br>");
  for(int i = 0;i < mydata.length;i++) {
   out.println(mydata[i]+"<br>");
  }
 }
 rs.close();

 stmt.close();
 jdbcConn.close();
}
catch(Exception e) {
 out.println(e);
}
%>
============================================================================
======

Thanks,
Srinivasan



"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly Prohibited.
If you have received this message by error, please notify us
immediately, return the original mail to the sender and delete the
message from your system."

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to