POJO - Pictures, Blob ot byte[]

Hi All,
the POJO Reporting works fine but
How can i include a picture into my Report ??
If i move my object (with a Blob and byte[]) into myReport.rpt the Blob and the byte[] does not become available for reporting.
What is wrong ??
Thanks for Your help
René
My Object:
public class RhuPlakatData {
private String text11;
private Blob blob1;
private byte[] bytes;
public byte[] getBytes() {
return bytes;
public void setBytes(byte[] bytes) {
this.bytes = bytes;
public String getText11() {
return text11;
public void setText11(String text11) {
this.text11 = text11;
public Blob getBlob1() {
return blob1;
public void setBlob1(Blob blob1) {
this.blob1 = blob1;

Hi James
Unfortunately, I found no solution.
Did You found a solution??
Thanks for Your help
Greetings
René

Similar Messages

  • Blob to byte[] detach failure

    Hi,
    I'm unable to detach a byte array using Kodo 3.3.4 and PostgreSQL 8.0. The
    byte array in the detached object is always empty despite there being
    bytes in the database table for the correspond column/row. Other fields
    are detached correctly.
    In my JDO file -
    <field name="image">
    <!-- Map image to BLOB field -->
    <extension vendor-name="kodo" key="jdbc-field-map-name" value="blob">
    <extension vendor-name="kodo" key="column" value="image"/>
    </extension>
    </field>
    This correctly creates a column of named 'image' of type 'bytea' in the
    table.
    This issue isn't listed in the know issues for PostgresQL - can anybody
    else confirm they have this working with this database? I see there was a
    similar problem with mySQL posted here, but then that issue wasn't
    documented either.
    Thanks,
    Andy.

    byte[] fields aren't in the default fetch group by default, and
    detachment only occurs on fields in the DFG. Both of these options
    (whether the field is in the DFG, and whether detachment works on DFG
    fields or uses some other criteria), are configurable. I assume you
    know how to control DFG settings; the documentation on detachment is here:
    http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_remote.html#ref_guide_detach_graph

  • Exception getting blob to byte[]

    Hy guys,
    I 've a problem with my java application.
    I use hibernate to interact with a derby database.
    I stored a image into blob field (and no problem).
    When I try to get blob to array of byte I've this exception:
    java.sql.SQLException: You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back.To get blob I did
    Blob cThumnb = ((Allegato) cAllegati.get(i)).getThumb();
    byte[] cPrev = toByteArray(cThumnb);where
    private byte[] toByteArray(Blob fromBlob) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                return toByteArrayImpl(fromBlob, baos);
            catch (SQLException e)
                throw new RuntimeException(e);
            catch (IOException e)
                throw new RuntimeException(e);
            finally
                if (baos != null)
                    try
                        baos.close();
                    catch (IOException ex)
        private byte[] toByteArrayImpl(Blob fromBlob, ByteArrayOutputStream baos)  throws SQLException, IOException
            byte[] buf = new byte[4000];
            InputStream is = fromBlob.getBinaryStream();
            try
                for (;;)
                    int dataSize = is.read(buf);
                    if (dataSize == -1)     break;
                    baos.write(buf, 0, dataSize);
            catch(IOException ex)
                    throw ex;
           finally
                if (is != null)
                    try
                        is.close();
                    catch (IOException ex)
                    return  buf;// baos.toByteArray();
        }Could you help me?
    I set also autocommit to false,
    Thanks,
    Regards

    EJP wrote:
    So could you cite some references that show, in general, that one normally needs to process blobs as streams?The design. The name, which is an acroynm for Binary Large Object. The fact that they have a stream interface, like files and sockets.The idiom for loading does not require nor even recommend that one must process as a stream.
    And most of the time I do not process files nor sockets via streaming methodologies. I load them entirely, then process them.
    Actually for direct socket usage, excluding protocols like FTP, I don't believe I have ever streamed processing because in message based protocols the messages are very small.
    Presumably because the OP has one reference to 'thumb' as in thumbnail view?From the OP's first post: 'I stored a image into blob field'.I see. I have stored images in databases before. Excluding storage of medical media files they were all processed in memory because all were rather small.
    Certainly cases where one does in fact want to read an entire file into memory, before one starts processing it.Can't think of any, but in any case if you are able to process it as a stream you are wasting both time and space by not doing so.If I have any data that is in fact "large" I will keep that in mind. But, for example, I can't see processing a configuration file that consists of a couple hundred bytes via stream processing just because files allow for the possibility that one can process a large file.

  • BLOB to byte[] mapping

    Hi,
    In my table, one of the columns is of type BLOB. When I generate Java objects out of the database, the type of this column becomes java.sql.Blob. This seems to be the default mapping. I want it to be of type byte[].
    How do I configure Toplink Workbench to map it always as byte[]?

    Either value in the object model is valid. You can modify the generated class to hold a byte[].
    If you are using the Oracle thin JDBC driver you should map the byte[] attribute as a TypeConversionMapping and select the type to be java.sql.BLOB.
    Doug

  • Please help, I need to read blob and output in bytes from wwv_flow_files.

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
    if (blob==null) return null;
    try {
    InputStream in = blob.getBinaryStream();
    int len = (int) blob.length(); //read as long
    long pos = 1; //indexing starts from 1
    byte[] bytes = blob.getBytes(pos, len);
    in.close();
    return bytes;
    catch (Exception e) {
    System.out.println(e.getMessage());
    return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    The example on this page is showing how to read a blob in portions you determine yourself:
    http://apex.oracle.com/pls/otn/f?p=31517:91
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to display and save a picture stored as BLOB in MySQL database in Jsp?

    Hello i am doing a dataentry form where in i will display the picture stored as Blob in MySQL database to the browser. The form also allow changing the picture and updating the picture Blob in the database.
    How can i do it? I try this
    <img src'"<%=rs.getBlob("picture")%> but it doesn't display the picture.
    another thing, how can i save it in the database, if is use the file field in the html form?
    thanks in advance for your help.

    Hello i am doing a dataentry form where in i will display the picture stored as Blob in MySQL database to the browser. The form also allow changing the picture and updating the picture Blob in the database.
    How can i do it? I try this
    <img src'"<%=rs.getBlob("picture")%> but it doesn't display the picture.
    another thing, how can i save it in the database, if is use the file field in the html form?
    thanks in advance for your help.

  • Plesae help- needing to read a blob from db into bytes[]

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
         if (blob==null) return null;
         try {
         InputStream in = blob.getBinaryStream();
         int len = (int) blob.length(); //read as long     
    long pos = 1; //indexing starts from 1
         byte[] bytes = blob.getBytes(pos, len);           
    in.close();
         return bytes;     
    catch (Exception e) {
         System.out.println(e.getMessage());
         return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    Hi all,
    Can any of you please help me out?
    rgds,
    Suma.

  • How to store images in BLOB field in MySql database using java

    Hi....
    Currently am able to store character string into BLOB using byte array....in MySql.
    but i cannot store images or pictures.......
    to do this.........please help me out...............
    Thanx..........:)Bye...........

    Hello,
    I have done this for Oracle but it should be similar in MySQL also. Try reading thru these links below. Mail us if you have succeeded or not.
    http://forum.java.sun.com/thread.jspa?forumID=48&threadID=654086
    http://forum.java.sun.com/thread.jspa?forumID=48&threadID=384768
    http://forum.java.sun.com/thread.jspa?forumID=48&threadID=549705
    Thanks and regards,
    Pazhanikanthan. P

  • Oracle error ORA-01461when trying to insert into an ORACLE BLOB field

    I am getting Oracle error ‘ORA-01461: can bind a LONG value only  for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
    BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
    ORACLE version is 11.2.0.1
    The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
    Here is my code:
    <cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
    <cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
    <cfset file_mime = 'data:image/' & file_mime & ';base64,'>
    <cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
    <cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
    <cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
    <cffile action="readbinary" file="#ramfile#" variable="image_bin">
    <cffile action="delete" file="#ramfile#">
    <cfquery name="InsertImage" datasource="#datasource#">
    INSERT INTO test_images
    image_blob
    SELECT
    <cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
    FROM          dual
    </cfquery>

    Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.

  • Should I be able to update a Blob via a ResultSet? (11g driver exception)

    This code fails at the last line:
    stmt = conn.createStatement();
    String tableName = "TBL_esun01_PPP";
    stmt.execute("drop table TBL_esun01_PPP");
    stmt.execute("create table TBL_esun01_PPP (sid int not null primary key, blob_col blob)");
    stmt.close();
    //insert test data
    String blobContent = "WLS JDBC4 test for blob.";
    String blobContentUpdate = "WLS JDBC4 test for UpdateBlob. [Updated]";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(blobContent.getBytes());
    ByteArrayInputStream inputStreamUpdate = new ByteArrayInputStream(blobContentUpdate.getByte
    s());
    String insertSql = "INSERT INTO " + tableName + " VALUES (?, ?)";
    PreparedStatement pstmt = conn.prepareStatement(insertSql);
    int key = 1;
    pstmt.setInt(1, key);
    pstmt.setBlob(2, inputStream);
    pstmt.execute();
    pstmt.close();
    inputStream.close();
    //update data
    String querySql1 = "SELECT sid FROM " + tableName;
    String querySql2 = "SELECT sid, blob_col FROM " + tableName;
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    // we can get updatable resultset in the same way without lob object.
    // following updating can succeed.
    System.out.println("Get updatable resultset using: "+querySql1);
    ResultSet rs = stmt.executeQuery(querySql1);
    rs.next();
    rs.updateInt(1, 2);
    rs.updateRow();
    rs.close();
    inputStreamUpdate.close();
    System.out.println("Get updatable resultset using: "+querySql2);
    try {// failed to get updatable resultset
    rs = stmt.executeQuery(querySql2);
    rs.next();
    rs.updateBlob(2, inputStreamUpdate); // Fails here...
    The driver is 11.1.0.6.0-Production
    The DBMS is Oracle Database 11g Release 11.1.0.0.0 - Production
    Get updatable resultset using: SELECT sid FROM TBL_esun01_PPP
    Get updatable resultset using: SELECT sid, blob_col FROM TBL_esun01_PPP
    We can not get updatable Resultset. Exception message:
    java.sql.SQLException: Invalid operation for read only resultset: updateBlob
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.BaseResultSet.updateBlob(BaseResultSet.java:506)
    at TestUpdatableRS.test(TestUpdatableRS.java:84)
    at TestUpdatableRS.main(TestUpdatableRS.java:112)
    thanks,
    Joe

    Joe,
    a) I could not find updateBlob(int, java.io.InputStream). It is updateBlob(int, java.sql.Blob).
    b) I tried the below test and it worked fine, I am using the latest drivers.
    CREATE TABLE BLOB_TABLE (C1 NUMBER, C2 BLOB);
    INSERT INTO BLOB_TABLE VALUES(55, '101011');
    public static void test2(Connection conn) throws SQLException {
    System.out.println("test -");
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
    String query = "select c1, c2 FROM blob_table";
    pstmt = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    rs = pstmt.executeQuery();
    SQLWarning x = pstmt.getWarnings();
    if (x != null)
    System.out.println(x.getMessage());
    x = rs.getWarnings();
    if (x != null)
    System.out.println(x.getMessage());
    BLOB blob = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
    byte[] b = new byte[50];
    java.util.Arrays.fill(b, (byte) 53);
    blob.putBytes(1L, b);
    if (rs.next()) {
    rs.updateInt(1, 88);
    rs.updateBlob(2, blob);
    rs.updateRow();
    x = rs.getWarnings();
    if (x != null) {
    System.out.println(x.getMessage());
    } catch (SQLException ea) {
    System.out.println(ea);
    } finally {
    if (rs != null) {
    rs.close();
    if (pstmt != null) {
    pstmt.close();
    System.out.println("test - done");
    } // end of test2(Connection);
    ==
    Ashok

  • BLOB insert behavior with thin driver using standard JDBC2.0 and ORACLE-JDBC2.0API

    We have a problem with a BLOB insert to an oracle 8.1.7 DB using Oracle 8.1.7 JDBC thin driver.We get socket read/write error after inserting 32k of data using the standard JDBC2.0 API but using the Oracle JDBC2.0API (using OracleResultSet) it goes fine. We have a requirement to use the standard JDBC2.0 so that our code works with multiple database vendors. Is there another way to get in the blob data with standard JDBC API & using thin driver...?
    thanks,
    Madhu
    Here is my sample test program that does both standard & oracle specific JDBC Blob test insert.
    import java.sql.*;
    import java.io.*;
    import oracle.sql.BLOB;
    import oracle.jdbc.driver.OracleResultSet;
    public class testBLOB {
    //trying to insert a huge file to a BLOB
    static String fileName = "/kernel/genunix";
    public static void main(String[] args) {
    String driverName = "oracle.jdbc.driver.OracleDriver";
    String dbURL = "jdbc:oracle:thin:@localhost:1521:test"; //thin driver
    String user = "BlobTest";
    String passwd = "BlobTest";
    Connection con=null;
    try {
    Class.forName(driverName);
    con=DriverManager.getConnection(dbURL, user,passwd);
    catch (Exception e) {
    e.printStackTrace();
    close(con);
    int i = 0;
    while (i < args.length) {
    if (args.equals("-f"))
    fileName = args[++i];
    i++;
    System.out.println("The file being Stored is: "+fileName);
    createTable(con);
    insertUsingOracleAPI(con);
    insertUsingJDBC20API(con);
    //readDB(con);
    static String getFileName() {
    return fileName;
    public static void close(Connection con) {
    try {
    if (con != null) {
    con.close();
    catch (Exception e) {
    System.exit(-1);
    public static void createTable(Connection con) {
    Statement stmt ;
    try {
    stmt = con.createStatement();
    stmt.execute("DROP TABLE basic_blob_table");
    stmt.close();
    catch (SQLException sqlEx) {
    System.out.println("Dropped the Table");
    try {
    stmt = con.createStatement();
    stmt.execute("CREATE TABLE basic_blob_table ( x varchar2(30), b blob)");
    stmt.close();
    catch (SQLException sqlEx) {
    sqlEx.printStackTrace();
    close(con);
    System.out.println("Created the Table");
    public static void insertUsingOracleAPI(Connection con) {
    OutputStream os = null;
    Statement stmt = null;
    ResultSet rs = null;
    FileInputStream is = null;
    try {
    con.setAutoCommit(false);
    stmt = con.createStatement();
    stmt.execute("INSERT INTO basic_blob_table VALUES( 'OracleAPI', empty_blob())");
    System.out.println("Inserted the dummy Row");
    rs = stmt.executeQuery("Select * from basic_blob_table where x='OracleAPI'");
    if (rs != null && rs.next()) {
    BLOB blob = ((OracleResultSet)rs).getBLOB(2);
    File file = new File(getFileName());
    is = new FileInputStream(file);
    os = blob.getBinaryOutputStream();
    byte[] chunk = new byte[1024];
    int length = -1;
    while((length = is.read(chunk)) != -1)
    os.write(chunk, 0,length);
    System.out.println("Inserted the File " + getFileName() );
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    if (os != null) {
    os.flush();
    os.close();
    if (is != null)
    is.close();
    stmt.close();
    con.commit();
    con.setAutoCommit(true);
    catch (Exception e) {}
    public static void insertUsingJDBC20API(Connection con) {
    PreparedStatement stmt = null;
    FileInputStream is = null;
    try {
    stmt = con.prepareStatement("INSERT INTO basic_blob_table VALUES(?,?)");
    File file = new File(getFileName());
    is = new FileInputStream(file);
    stmt.setString(1,"JDBC20API");
    stmt.setBinaryStream(2,is,(int)file.length());
    stmt.executeUpdate();
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    if (is != null)
    is.close();
    stmt.close();
    catch (Exception e) {}
    null

    Thanks for the response.
    I understand what you are saying...
    that readers don't block writers in Oracle (the same is true in SQL Server 2000).
    However, I don't see how my test case is working correctly with Oracle (the exact same code acting as I'm thinking it should with SQL Server, but I still think it is acting incorrectly with Oracle).
    I have transaction A do this:
    update <table> set <column2>=<value> where <column1>='1'
    then I use Thread.sleep() to make that program hang around for a few minutes.
    Meanwhile I sneak off and start another program which begins transaction B. I have transaction B do this:
    select * from <table> where <column1>='1'
    and the read works immediately (no blocking... just as you have said) however, transaction A is still sleeping, it has not called commit() or rollback() yet.
    So what if transaction A were to call rollback(), the value read by transaction B would be incorrect wouldn't it ?
    Both A and B use setAutoCommit(false) to start their transactions, and then call setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED).
    Isn't that supposed to guarantee that a reader can only read what is committed ?
    And if a row is in "flux"... in the process of having one or more values changed, then the database cannot say what the value will be ?
    I can almost see what you are saying.
    In letting the reader have what it wants without making it wait, I suppose it could be said that Oracle is holding true to the "only let committed data be read"
    So if that's it, then what if I want the blocking ?
    I want an entire row to be locked until whoever it in the middle of updating, adding, or removing it has finished.
    Do you know if that can be done with Oracle ? And how ?
    Thanks again for helping me.

  • Error inserting BLOBs in OC4J 9.0.2.1

    The following snippet of code works in oc4j 9.0.2.0.0 but not in OC4J 9.0.2.1 Any ideas why?
    Thanks,
    Rajiv
    FileInputStream in = new FileInputStream(file.getPath());
    conn.setAutoCommit(false);
    ps = conn.prepareStatement("SELECT blob_info FROM trx_blob WHERE trx_blob_id = ? FOR UPDATE");
    ps.setInt(1, blobID);
    rs = ps.executeQuery();
    rs.next();
    BLOB blob = ((OracleResultSet) rs).getBLOB(1);
    OutputStream outStream = blob.getBinaryOutputStream();
    int size = blob.getBufferSize();
    byte[] buffer = new byte[size];
    int length = -1;
    while ((length = in.read(buffer)) != -1) {
    outStream.write(buffer, 0, length);
    outStream.close();
    in.close();
    conn.commit();
    The error I get is java.sql.SQLException: ORA-01002: fetch out of seqence

    Rajiv -- This looks like bug 2541604. Please ask your support representative for a patch.
    Thanks -- Jeff

  • Using JSP/Servlet to write Word Document to BLOB

    Hi
    I need some help pls
    When I use a normal class with a main method, it loads the word document into a blob and I can read this 100%.Stunning.
    With a JSP/Servlet I cannot get the document out again. The "format" seems to be lost.
    Any ideas,help greatly appreciated:
    Here is the Main class that works:
    package mypackage1;
    import java.io.OutputStream;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.*;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class TestLOB
    //static final Logger logger = Logger.getLogger("test");
    public TestLOB()
    public static void main(String args[])
    TestLOB testLOB = new TestLOB();
    testLOB.TestLOBInsert("c:\\my_data\\callcenterpilot.doc");
    public void TestLOBInsert(String fileName)
    Connection conn = getConnection("wizard");
    BLOB blob = null;
    try
    conn.setAutoCommit(false);
    String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
    PreparedStatement pstmt = conn.prepareStatement(cmd);
    ResultSet rset = pstmt.executeQuery(cmd);
    rset.next();
    blob = ((OracleResultSet)rset).getBLOB(2);
    File binaryFile = new File(fileName);
    System.out.println("Document length = " + binaryFile.length());
    FileInputStream instream = new FileInputStream(binaryFile);
    OutputStream outstream = blob.getBinaryOutputStream();
    int size = blob.getBufferSize();
    byte[] buffer = new byte[size];
    int length = -1;
    while ((length = instream.read(buffer)) != -1)
    outstream.write(buffer, 0, length);
    instream.close();
    outstream.close();
    conn.commit();
    closeConnection(conn);
    catch (Exception ex)
    System.out.println("Error =- > "+ex.toString());
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    DriverManager.registerDriver(new OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:@oraclu5:1600:dwz110","so_cs","so_cs");
    catch (Exception ex)
    System.out.println("Error getting conn"+ex.toString());
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    System.out.println("Error closing connection in get last imei"+se.toString());
    Works fine:
    Here is the display servlet: Works when main class inserts file
    package mypackage1;
    import java.io.InputStream;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.*;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class DisplayLOB extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    static final Logger logger = Logger.getLogger(DisplayLOB.class);
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    //response.setContentType(CONTENT_TYPE);
    //PrintWriter out = response.getWriter();
    Connection conn = null;
    PreparedStatement pstmt = null;
    try
    conn = getConnection("wizard");
    //out.println("<html>");
    //out.println("<head><title>DisplayLOB</title></head>");
    //out.println("<body>");
    //out.println("<p>The servlet has received a POST. This is the reply.</p>");
    InputStream is=null;
    oracle.sql.BLOB blob=null;
    response.setContentType("application/msword");
    //response.setContentType("audio/mpeg");
    OutputStream os = response.getOutputStream();
    String term = "1";
    String query = "SELECT docdetail FROM testlob WHERE docno = 1";
    pstmt = conn.prepareStatement(query);
    ResultSet rs = pstmt.executeQuery();
    while (rs.next())
    blob=((OracleResultSet)rs).getBLOB(1);
    is=blob.getBinaryStream();
    int pos=0;
    int length=0;
    byte[] b = new byte[blob.getChunkSize()];
    while((length=is.read(b))!= -1)
    pos+=length;
    os.write(b);
    }//try
    catch (Exception se)
    se.printStackTrace();
    finally
    try
    pstmt.close();
    catch (Exception ex)
    System.out.println("Error closing pstmt "+ex.toString());
    //out.println("</body></html>");
    //out.close();
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    conn = DataBase.getPoolConnection(dataBase);
    catch (Exception se)
    logger.fatal("Error getting connection: ",se);
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    logger.error("Error closing connection in get last imei",se);
    Here is JSP/Servlet
    <%@ page import="org.apache.log4j.*"%>
    <%@ page contentType="text/html; charset=ISO-8859-1" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>untitled</title>
    <title>Wizard SMS Interface</title>
    <link rel='stylesheet' type='text/css' href='main1.css'>
    <script language='JavaScript' src='copyright.js'></script>
    </head>
    <pre>
    <%
    //HTTP 1.1
    response.setHeader("Cache-Control","no-cache");
    //HTTP 1.0
    response.setHeader("Pragma","no-cache");
    //prevents caching at the proxy server
    response.setDateHeader ("Expires", 0);
    Logger logger = Logger.getLogger("co.za.mtn.wizard.administration.admin01.jsp");
    %>
    </pre>
    <body>
    <FORM ACTION="/WizardAdministration/uploadfile"
    METHOD="POST"
    ENCTYPE="multipart/form-data">
    <INPUT TYPE="FILE" NAME="example">
    <INPUT TYPE="SUBMIT" NAME="button" VALUE="Upload">
    </FORM>
    </body>
    </html>
    <font> <b>Copyright &copy;
    <script>
    var LMDate = new Date( document.lastModified );
    year = LMDate.getYear();
    document.write(display(year));
    </script>
    Mobile Telephone Networks.
    <p align="left"><i><b><font face="Georgia, Times New Roman, Times, serif" size="1"></font></b></i></p>
    package co.za.mtn.wizard.admin;
    import java.io.InputStream;
    import java.util.Enumeration;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.Writer;
    import java.sql.Connection;
    import oracle.jdbc.OracleResultSet;
    import oracle.sql.BLOB;
    import org.apache.log4j.Logger;
    import Util_Connect.DataBase;
    public class UploadFile extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    //static final Logger logger = Logger.getLogger(UploadFile.class);
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    String headerName = null;
    Enumeration en = request.getHeaderNames();
    try
    while ( en.hasMoreElements() )
    Object ob = en.nextElement();
    headerName = ob.toString();
    System.out.println("Value for headerNAme is >"+headerName+"<");
    String aaa = request.getHeader(headerName);
    System.out.println("Value for aa is >"+aaa+"<");
    catch (Exception ex)
    System.out.println("Error in extracting request headers"+ex.toString());
    Connection conn = getConnection("wizard");
    BLOB blob = null;
    try
    conn.setAutoCommit(false);
    String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
    PreparedStatement pstmt = conn.prepareStatement(cmd);
    ResultSet rset = pstmt.executeQuery(cmd);
    rset.next();
    blob = ((OracleResultSet)rset).getBLOB(2);
    //File binaryFile = new File("h:\\callcenterpilot.doc");
    //System.out.println("Document length = " + binaryFile.length());
    //FileInputStream instream = new FileInputStream(binaryFile);
    response.setHeader("Content-Type","application/vnd.ms-word");
    String contentType = request.getContentType();
    System.out.println("Content type received in servlet is >"+contentType+"<");
    ServletInputStream instream = request.getInputStream();
    OutputStream outstream = blob.getBinaryOutputStream();
    int size = blob.getBufferSize();
    byte[] buffer = new byte[size];
    int length = -1;
    while ((length = instream.read(buffer)) != -1)
    outstream.write(buffer, 0, length);
    instream.close();
    outstream.close();
    conn.commit();
    closeConnection(conn);
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    catch (Exception ex)
    System.out.println("Error =- > "+ex.toString());
    //out.println("</body></html>");
    //out.close();
    private Connection getConnection(String dataBase)
    Connection conn = null;
    try
    conn = DataBase.getPoolConnection(dataBase);
    catch (Exception se)
    System.err.println("Error getting connection: "+se.toString());
    return conn;
    private void closeConnection(Connection conn)
    if (conn != null)
    try
    conn.close();
    catch (Exception se)
    System.err.println("Error closing connection in get last imei"+se.toString());
    This is what the display servlet is showing when the JSP/Servlet insert the document
    -----------------------------7d31422224030e
    Content-Disposition: form-data; name="example"; filename="H:\(your name) Skills Matrix.doc"
    Content-Type: application/msword
    �� ࡱ � > ��     � � ���� � � ���������������������
    Tks
    Andre

    hello,
    there are multiple documents out there, describing the oracle reports server setup. try doc.oracle.com for documentation.
    also it is part of the online-documentation.
    you need to install 9iAS enterprise edition. the server is pre-configured and will listen to the url http://yourserver/dev60cgi/rwcgi60.exe
    passing only this url you will get a help-screen, describing the syntax.
    regards,
    the oracle reports team

  • How to transfer a blob column in a table to another blob column in another

    Well as the title suggest, i'm trying to take the BLOB field in say my table Photo and put it in another BLOB field in my table Members. How would i do that?
    I'm working in Oracle Forms 10G.
    I tried to do a cursor that get the picture(BLOB) and i tried to fetch the result in the other table :Members.Photo but it says my link is not good. I also tried using variables but didn't do the trick either.
    The thing is we have a system that once the picture is taken its automatically put in the Photo table (contain only one picture at a time, only one row) and then in Forms we have have a message asking to press ok when the photo has been taken and then it should insert it in the Members table....
    if more information is required please feel free to ask!
    Thanks in advance.

    INSERT INTO CLIENTS_PHOTOS (
      CLPHOTO_ID,
      CL_ID,
      DTHRS_PHOTO,
      PHOTO,
      SIGNATURE,
      CREE_LE,
      CREE_PAR,
      MODIFIE_LE,
      MODIFIE_PAR
    )  SELECT :NOUVELLE_PHOTO.CLPHOTO_ID,
              CLIENT.CL_ID,
              SYSDATE,
              PS.PHOTO,
              PS.SIGNATURE,
              SYSDATE,
              :NOUVELLE_PHOTO.L_CD_USER,
              SYSDATE,
              :NOUVELLE_PHOTO.L_CD_USER
         FROM PHOTO_SIGNATURE PS;Looks quite ok so far. Did you try to issue that insert manually in SQL*plus? Also, is it correct that there is no WHERE-condition in your select?

  • Displaying BLOB from Database

    Hi All,
    I am trying to preview a 'jpeg' image which is stored in my database. The images get inserted into the DB without any trouble, but on retrieving the images I get 'broken links' to the images. Please Help:
    PROCEDURE GET_TEAM_LOGO(team_name VARCHAR2)
    AS
    vblob BLOB;
    buf RAW(32000);
    buf_size INTEGER := 32000;
    offset INTEGER := 1;
    len NUMBER;
    mime_type VARCHAR2(30);
    BEGIN
    auth_proc;
    -- get image_data and its mime type from the database
    WHERE LOGO_ID=position;
    htp.p('This is the value of team:'|| team_name ||'<br>');
    SELECT logo_image, logo_type INTO vblob, mime_type
    FROM LOGO_TABLE
    WHERE group_name = team_name;
    -- set the mime type for the http protocol
    owa_util.mime_header('image/jpeg');
    -- read the data with htp package
    len:=dbms_lob.getlength(vblob);
    WHILE offset < len LOOP
    dbms_lob.read(vblob,buf_size,offset,buf);
    htp.prn(utl_raw.cast_to_varchar2(buf));
    offset:=offset+buf_size;
    END LOOP;
    -- check for exception
    EXCEPTION
    WHEN OTHERS THEN
    htp.p(SQLCODE || SQLERRM);
    END;
    Thanks,
    Peter

    Hi!
    I've used this code successfylly in a mod_plsql procedure.
    Can be used as following:
    htp.img('http://yourhost:port/<dad>/image.get_image?p_picture_id=123,'"right"',null,null,'width=107 height=66 border=1');
    procedure get_image
    ( p_picture_id number
    ) as
    cursor c_pict
    ( b_picture_id number
    ) is
    select pict.picture -- blob column
    , pict.format -- Gif/Jpeg etc.
    from pictures pict
    where pict.picture_id = b_picture_id
    r_pict c_pict%rowtype;
    v_blob BLOB;
    v_amt NUMBER := 30;
    v_off NUMBER := 1;
    v_raw RAW(4096);
    begin
    open c_pict(p_picture_id);
    fetch c_pict into r_pict;
    if c_pict%notfound
    then
    close c_pict;
    else
    close c_pict;
    owa_util.mime_header('image/'||r_pict.format);
    begin
    loop
    dbms_lob.read(r_pict.picture,v_amt,v_off,v_raw);
    htp.prn(utl_raw.cast_to_varchar2(v_raw));
    v_off := v_off+v_amt;
    v_amt := 4096;
    end loop;
    exception
    when no_data_found
    then
    null;
    end;
    end if;
    end get_image;

Maybe you are looking for

  • HT3529 i am unable to send sms from my iphone 4s

    i am unable to send sms from my iphone 4s

  • How do you double underline in pages 5.2

    I am not able to find how to double underline in the pages update 5.2  Making documents previously I was able to select a colour for text then single or double underline in a different colour.  It seems now that there is only the option of  text and

  • RAID 1 recovery... stuck!

    Hi folks - I installed 2 160g SATA drives (WD ones) a while back and configured them as RAID 1. They've been working away fine for quite a while, but today the machine froze a couple of times and then finally bluescreened on restart - the RAID bios t

  • From knowledge Art to email error Reference Link not created

    Just upgraded to Solman 7.1 SP10 When I have created a knowledge article I use "MORE - > Create follow up", select email to send the knowledge article to a user, then I get this message : "Reference Link not created as this Object Reference is not cu

  • SRM 7.0 - Translation of the description of attributes in table T770MATTR

    Hello, I need to translate the description texts of custom attributes in table T770MATTR using SE63. Currently I'm looking for the object type of these texts, but unfortunately I couldn't find it so far. Can anybody help me regarding this issue? Best