Insert BLOB problem

Hi:
I'm using oracle 8.1.6 on SunOS 5.7.
I tried to insert a MS Word file into a blob column, but failed.
Following are what I did:
create table test
(id number primary key,
text blob
insert into test (id,text) values (1,empty_blob());
create directory filedir as '/home/mydir';
Declare
lobd BLOB;
fils BFILE;
BEGIN
fils := BFILENAME('filedir','test.doc');
SELECT text INTO lobd FROM test WHERE id = 1 FOR UPDATE;
dbms_lob.fileopen(fils, dbms_lob.file_readonly);
dbms_lob.loadfromfile(lobd, fils, dbms_lob.getlength(fils));
COMMIT;
dbms_lob.fileclose(fils);
END;
I got error message:
DECLARE
ERROR at line 1:
ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "SYS.DBMS_LOB", line 475
ORA-06512: at line 7
The file test.doc is at that directory /home/mydir. I tried to replace
'filedir' with '/home/mydir' in the line
fils := BFILENAME('filedir','test.doc');
but still no success.
Could anyone give me some advices?
Thanks,
George

Hi Omar,
Could anyone tell me how to insert a file (say a word doc., or a PDF or a text document) into a column of a table of type BFILE or BLOB. I know that it is possible to map to the physical file on the filesystem thru logical directory creation. But, would like to know how to insert a file into the column and use it later for retireval, string searching, etc. from the queries. Is it thru SQL*Loader? Could u explain me(with example, if poss.) how to do this with the loader utility?
Pls guide me thru this.
Thanks!
Regards,
Sanjay

Similar Messages

  • RegisterOutParameter - setBinaryStream - Problems inserting Blob - setRAW

    As posted in metalink (was: "Problems inserting BLOB/InputStream with ojdbc14.jar for 10g - Data size bigger than max size for this type"):
    Using setBinaryStream for large Blobs works as long as I don't register outParameters.
    Query that works: "INSERT INTO blobtest (attachment_id,name,data) VALUES(blobtest_SEQ.nextval,?,?)";
    Query that fails = "BEGIN INSERT INTO blobtest (attachment_id,name,data) VALUES( blobtest_SEQ.nextval,?,?) RETURN attachment_id INTO ? ; END;"
    The necessary tables were created by hand:
    CREATE TABLE blobtest ( NAME CHAR(255), data BLOB, attachment_id NUMBER(38))
    And
    CREATE SEQUENCE TBL_ATTACHMENT_SEQ
    The output was: <<user: SEE
    pw: QD
    instantiating oracle driver
    query: INSERT INTO blobtest (attachment_id,name,data) VALUES(TBL_ATTACHMENT_SEQ.nextval,?,?)
    uploaded no Return Parameter blob of size: 256809
    query: BEGIN INSERT INTO blobtest (attachment_id,name,data) VALUES(TBL_ATTACHMENT_SEQ.nextval,?,?) RETURN attachment_id INTO ? ; END;
    java.sql.SQLException: Datengr÷&#9600;e gr÷&#9600;er als max. Gr÷&#9600;e f³r diesen Typ: 256809
    at
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :125)
    at
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :162)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setRAW(OraclePreparedState
    ment.java:5342)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setBinaryStreamInternal(Or
    aclePreparedStatement.java:6885)
    at
    oracle.jdbc.driver.OracleCallableStatement.setBinaryStream(OracleCall
    ableStatement.java:4489)
    at BlobTest.writeBlob(BlobTest.java:161)
    at BlobTest.testBlob(BlobTest.java:118)
    at BlobTest.main(BlobTest.java:92)
    error: Datengr÷&#9600;e gr÷&#9600;er als max. Gr÷&#9600;e f³r diesen Typ:
    256809>>
    here the java test case:
    * Created on 25.08.2004 $Id: BlobTest.java,v 1.4 2005/04/22 11:21:11 hauser Exp $
    * as posted in metalink jdbc forum 050405 and responses by
    * [email protected]
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.Types;
    public class BlobTest {
    private static String FILE_NAME = "c:/temp/veryLargeFile.pdf";
    public BlobTest() {
    final static int ORACLE = 1;
    final static int MYSQL = 2;
    private String jdbcUrl = "jdbc:mysql://localhost/test?user=monty&password=greatsqldb";
    private int dbType = ORACLE;
    private Driver driver = null;
    private String user = "";
    private String pw = "";
    public static String SCHEME = "";
    public static void main(String[] args) {
    BlobTest bt = new BlobTest();
    if (args[0] != null) {
    System.out.println("dbType: " + args[0]);
    if (args[0].toLowerCase().indexOf("oracle") != -1) {
    bt.dbType = ORACLE;
    if (args[0].toLowerCase().indexOf("mysql") != -1) {
    bt.dbType = MYSQL;
    } else {
    System.out.println("not yet supported db type: " + args[0]);
    System.exit(99);
    if (args[1] != null) {
    System.out.println("jdbcUrl: " + args[1]);
    if (args[1].trim().length() != 0) {
    bt.jdbcUrl = args[1].trim();
    } else {
    System.out.println("not yet supported jdbcUrl : " + args[1]);
    System.exit(99);
    if (args.length > 2 && args[2] != null) {
    System.out.println("user: " + args[2]);
    if (args[2].trim().length() != 0) {
    bt.user = args[2].trim();
    } else {
    System.out.println("invalid user: " + args[2]);
    System.exit(99);
    if (args.length > 3 && args[3] != null) {
    System.out.println("pw: " + args[3].substring(0, 2));
    if (args[3].trim().length() != 0) {
    bt.pw = args[3].trim();
    } else {
    System.out.println("invalid filename: " + args[3]);
    System.exit(99);
    if (args.length > 4 && args[4] != null) {
    System.out.println("filename: " + args[4]);
    if (args[4].trim().length() != 0) {
    FILE_NAME = args[4].trim();
    } else {
    System.out.println("invalid filename: " + args[4]);
    System.exit(99);
    bt.setUp();
    bt.testBlob();
    public void setUp() {
    try {
    if (this.dbType == ORACLE) {
    System.out.println("instantiating oracle driver ");
    this.driver = (Driver) Class.forName(
    "oracle.jdbc.driver.OracleDriver").newInstance();
    } else {
    this.driver = (Driver) Class.forName("com.mysql.jdbc.Driver")
    .newInstance();
    if (this.driver == null) {
    System.out.println("oracle driver is null");
    System.exit(88);
    DriverManager.registerDriver(this.driver);
    } catch (Exception e) {
    e.printStackTrace();
    System.out.println("error: " + e.getMessage());
    public void testBlob() {
    try {
    this.writeBlob();
    } catch (Exception e) {
    e.printStackTrace();
    System.out.println("error: " + e.getMessage());
    * testfunction
    private void writeBlob() throws Exception {
    Connection conn = null;
    PreparedStatement pStmt = null;
    CallableStatement cStmt, cStmt2 = null;
    InputStream in = null;
    try {
    File file = new File(BlobTest.FILE_NAME);
    in = new FileInputStream(file);
    conn = DriverManager.getConnection("jdbc:" + this.jdbcUrl,
    this.user, this.pw);
    conn.setAutoCommit(false);
    String queryWorks = "INSERT INTO " + SCHEME
    + "blobtest (attachment_id,name,data) VALUES(" + SCHEME
    + "TBL_ATTACHMENT_SEQ.nextval,?,?)";
    cStmt = conn.prepareCall(queryWorks);
    System.out.println("query: " + queryWorks);
    cStmt.setString(1, file.getAbsolutePath());
    in = new FileInputStream(file);
    cStmt.setBinaryStream(2, in, (int) file.length());
    cStmt.execute();
    System.out.println("uploaded no Return Parameter blob of size: "
    + file.length());
    conn.commit();
    String queryFails = "BEGIN INSERT INTO " + SCHEME
    + "blobtest (attachment_id,name,data) VALUES(" + SCHEME
    + "TBL_ATTACHMENT_SEQ.nextval,?,?)"
    + " RETURN attachment_id INTO ? ; END;";
    cStmt2 = conn.prepareCall(queryFails);
    System.out.println("query: " + queryFails);
    cStmt2.setString(1, file.getAbsolutePath());
    in = new FileInputStream(file);
    cStmt2.setBinaryStream(2, in, (int) file.length());
    cStmt2.registerOutParameter(3, Types.INTEGER);
    cStmt2.execute();
    System.out.println("uploaded blob of size: " + file.length()
    + " - id: " + cStmt2.getInt(3));
    conn.commit();
    } catch (Exception e) {
    e.printStackTrace();
    System.out.println("error: " + e.getMessage() + "\nname: "
    + BlobTest.FILE_NAME);
    if (conn != null) {
    try {
    conn.rollback();
    } catch (Exception e1) {
    throw e;
    } finally {
    if (in != null) {
    try {
    in.close();
    } catch (Exception e) {
    if (pStmt != null) {
    try {
    pStmt.close();
    } catch (Exception e) {
    if (conn != null) {
    try {
    conn.close();
    } catch (Exception e) {
    and the batch file I use to start:
    @setlocal
    @echo off
    rem $Id: runBlobTest.bat,v 1.2 2005/04/21 15:06:22 hauser Exp $
    set classpath=../WEB-INF/classes;../WEB-INF/lib/ojdbc14.jar;
    echo JAVA_HOME: %JAVA_HOME%
    set JAVA_HOME=C:\PROGRA~1\Java\j2re1.4.1_02\
    echo classpath: %classpath%
    set javaCmd=C:\PROGRA~1\Java\j2re1.4.1_02\bin\java
    %javaCmd% -version
    %javaCmd% BlobTest "oracle" "oracle:thin://@ORADB.yourdomain.COM:1521:t300" "username" "password" "C:\Temp\veryLargeFile.pdf"
    endlocal

    Apparently, this is partially known - with a different stacktrace though:
    <<From: Oracle, Anupama Srinivasan 25-Apr-05 07:15
    Can you please check on Bug:4083226?
    Using the RETURNING Clause is not supported with JDBC. You could embed the statement in PL/SQL Block as in Metalink Note 124268.1 - JDBC Support for DML Returning Clause.
    The Enhancement Request filed on this issue is being considered for Release 10.2
    >>
    And my answer to it.
    Using the RETURNING Clause is not supported with JDBC.This is strange, with just "emptyblob()", it DOES work.
    I guess, our work-around that hopefully is more portable than embedding a "PL/SQL Block" will be to
    1) create the record with an empty blob,
    2) update the blob in a second statement (now, a RETURNING statement is no longer needed)

  • Blob Problem

    Hello,
    The problem that i have is that i want to insert a file residing in the network into the oracle database into a blob field and again read it from the database and show it ie either insert it into a file directly and then open it using the correct editor or open it directly. I am using java along with it but i am basically stuck on the database side.
    I am sending the code which i have written till date
    i basically need to know
    1)the syntax i am using to interact with the database is right ie where is the error in the code
    2)provided that is ok whether my overall code is on the right track.
    The error message i am getting:
    java.sql.exe:ORA-06550 line col22
    PLS 00302: Component GETCHUNKSIZE must be declared
    ORA-06550 line1 col 7
    pl/sql statement ignoured
    My developopment enviornment is JDeveloper3.0 as this code is having problems compiling in JDK as Jdeveloper overides a few of the jdk classes.
    =========================================================================
    My table structure
    CREATE TABLE DOC_MAS(
    DOC_MAS_SR_NO NUMBER(10),
    PROJECT_NAME VARCHAR2(30),
    MODULE_NO NUMBER(10),
    DOC_NAME VARCHAR2(10),
    DOC_TYPE VARCHAR2(10),
    VERSION NUMBER(10));
    CREATE SEQUENCE SEQ_DOC_MAS START WITH 1 INCREMENT BY 1;
    CREATE SEQUENCE SEQ_DOC_DETAIL START WITH 1 INCREMENT BY 1;
    CREATE TABLE DOC_DETAIL(
    DOC_DETAIL_SR_NO NUMBER(10),
    DOC_MAS_SR_NO NUMBER(10),
    DATE_OF_INSERT DATE,
    ACTUAL_DOC BFILE,
    COMMENTS VARCHAR2(500));
    ===============================================================================
    My connection code:
    public class ConnectionParams {
    // The machine on which the database resides
    //public final static String s_hostName = "insn110a.in.oracle.com";
    public final static String s_hostName = "192.168.1.1";
    // The TNS listener port
    public final static String s_portNumber = "1521";
    // The database name (SID)
    //public final static String s_databaseSID = "otndb";
    public final static String s_databaseSID = "orcl";
    // The database User ID
    public final static String s_userName = "scott";
    // The database user password
    public final static String s_password = "tiger";
    ========================================================================================
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    import java.util.*;
    import java.util.Date;
    //import java.math.BigDecimal;
    public class Sample2
    Connection m_connection; //Database Connection Object
    String p_doc_name=null;
    String s_blobvariable = p_doc_name;
    public Sample2()
    dbConnection();
    public static void main(String[] args)
    Sample2 lobs = new Sample2();
    // lobs.dbConnection();
    lobs.readFileNameExt();
    /*This class is for creation of connection =========================================*/
    public void dbConnection() {
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String l_dbConnectString =
    "(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
    "(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
    "(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
    m_connection = DriverManager.getConnection(
    "jdbc:oracle:thin:@"+l_dbConnectString,
    ConnectionParams.s_userName, ConnectionParams.s_password);
    // m_connection.setAutoCommit(false);
    System.out.println("Connection Successful");
    Thread.sleep(3000);
    } catch(Exception ex){ //Trap SQL errors
    System.out.println("Error in Connecting to the Database "+ex.toString());
    /*========================================================================================
    File inserting section of the code
    // THIS class gets the input from the file dialog box it gets the file path,projectName and the module no
    //public void readFileNameExt(String p_doc_path,String p_module_no,String p_project_name)
    public void readFileNameExt()
    String p_doc_path = "c:/warea/Mehul2/TABLE5.xls";
    int p_module_no = 10;
    String p_project_name = "Finserve";
    String p_doc_type= null;
    String p_version = null;
    StringTokenizer strtkn = new StringTokenizer(p_doc_path,"/");
    while(strtkn.hasMoreTokens())
    p_doc_name =strtkn.nextToken();
    System.out.println("The file name is" +p_doc_name);
    StringTokenizer strtoken = new StringTokenizer(p_doc_name,".");
    while(strtoken.hasMoreTokens())
    p_doc_type =strtoken.nextToken();
    try{
    System.out.println("The file Type is"+p_doc_type);
    insertDocMas(p_doc_name,p_doc_type,p_project_name,p_module_no);
    Thread.sleep(10000);
    }catch (Exception e){}
    }//end of method
    //============================================== this class is for inserting the doc_mas details in teh table along with version checking
    public void insertDocMas(String p_doc_name,String p_doc_type,String p_project_name,int p_module_no){
    int p_version = -1;
    int p_doc_mas_sr_no = -1;
    // String verision=null;
    int verision;
    String s = null;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_version_details = l_stmt.executeQuery("SELECT MAX(VERSION) FROM DOC_MAS WHERE DOC_NAME = '"+p_doc_name+"'");
    if (l_version_details.next())
    { System.out.println("The Control 1");
    verision = l_version_details.getInt(1);
    System.out.println("The Control 2 : "+verision);
    verision = verision +1;
    else {
    verision = 1;
    System.out.println("The Control 3");
    p_version = verision;
    System.out.println("The value of p_version" + p_version);
    l_version_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert"+e);
    /* try{
    Statement stmt = m_connection.createStatement();
    ResultSet rset = stmt.executeQuery("select DEPTNO,DNAME,LOC from DEPT");
    while(rset.next()){
    BigDecimal deptno = rset.getBigDecimal(1,2);
    String dname = rset.getString(2);
    // Timestamp hiredate = rset.getTimestamp(3);
    String loc = rset.getString(3);
    System.out.println(deptno+" "+dname+" "+loc);
    Thread.sleep(50000);
    }catch(Exception e){System.out.println(e);}
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_details = l_stmt.executeQuery("SELECT SEQ_DOC_MAS.NEXTVAL FROM DUAL");
    if (l_seq_details.next())
    p_doc_mas_sr_no = l_seq_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_mas_sr_no" + p_doc_mas_sr_no);
    l_seq_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try {
    System.out.println("Creating rows in DOC_MAS.. ");
    System.out.println("The Control VV");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_MAS(DOC_MAS_SR_NO,PROJECT_NAME,MODULE_NO,DOC_NAME,DOC_TYPE,VERSION) values(?,?,?,?,?,?)");//SEQ_DOC_MAS.nextval
    l_pstmt.setInt(1,p_doc_mas_sr_no);//"SEQ_DOC_DETAIL.NEXTVAL"
    l_pstmt.setString(2,p_project_name);
    l_pstmt.setInt(3,p_module_no);
    l_pstmt.setString(4,p_doc_name);
    l_pstmt.setString(5,p_doc_type);
    l_pstmt.setInt(6,p_version);
    l_pstmt.executeUpdate(); // Execute SQL statement
    l_pstmt.close();
    System.out.println("The Control 3");
    // Close statement
    Thread.sleep(20000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert11"+e);
    try{System.out.println("The Control 4");
    Statement l_statement = m_connection.createStatement();
    ResultSet l_doc_mas_sr_no = l_statement.executeQuery(
    "SELECT max(DOC_MAS_SR_NO) FROM DOC_MAS "+
    "WHERE DOC_NAME = '"+p_doc_name+"' ");//FOR UPDATE
    if (l_doc_mas_sr_no.next())
    p_doc_mas_sr_no = l_doc_mas_sr_no.getInt(1);
    l_doc_mas_sr_no.close();
    l_statement.close();
    System.out.println("The Control 5");
    Thread.sleep(10000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert");
    loadSamples(p_doc_mas_sr_no,p_doc_name,p_doc_type);
    }//Method insertDocMas() closing here
    /*This class is for loading the data into the database==================================*/
    public void loadSamples(int p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    int p_doc_detail_sr_no = -1;
    Date p_sysdate = new Date() ;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_doc_details = l_stmt.executeQuery("SELECT SEQ_DOC_DETAIL.NEXTVAL FROM DUAL");
    if (l_seq_doc_details.next())
    p_doc_detail_sr_no = l_seq_doc_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_detail_sr_no" + p_doc_detail_sr_no);
    l_seq_doc_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try{
    Statement l_st = m_connection.createStatement();
    ResultSet l_date = l_st.executeQuery("SELECT sysdate FROM DUAL");
    if (l_date.next())
    p_sysdate = l_date.getDate(1);
    System.out.println("The Control sysdate");
    System.out.println("The value of p_sysdate" + p_sysdate);
    l_date.close();
    l_st.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the sysdate"+e);
    try {System.out.println("The Control 6");
    System.out.println("Creating row for actual-doc in DOC_DETAILS.. ");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT,ACTUAL_DOC)values(?,?,p_sysdate, empty_blob() )");
    l_pstmt.setInt(1,p_doc_detail_sr_no);
    l_pstmt.setInt(2,p_doc_mas_sr_no);
    //l_pstmt.setDate(3,p_sysdate);
    System.out.println("The Control 6AA");
    l_pstmt.execute(); // Execute SQL statement
    l_pstmt.close(); // Close statement
    System.out.println("Created.\nLoading <map.gif> into BLOB column for doc_detail...");
    System.out.println("The Control 7");
    // Retrieve the row just inserted, and lock it for insertion of the
    }catch(Exception e){
    System.out.println("Exception has occured at the time of inserting blob locators"+e);
    try {
    // LOB columns.
    System.out.println("The Control 7AAA");
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_lobDetails = l_stmt.executeQuery(
    "SELECT ACTUAL_DOC "+
    "WHERE DOC_MAS_SR_NO = '"+p_doc_mas_sr_no+"'");
    // Retrieve BLOB and CLOB streams for ACTUAL_DOC and TEXT_DOC
    // columns, and load the sample files
    System.out.println("The Control 8");
    if (l_lobDetails.next())
    // Get the BLOB locator and open output stream for the BLOB
    BLOB l_mapBLOB = ((OracleResultSet)l_lobDetails).getBLOB(1);
    OutputStream l_blobOutputStream = l_mapBLOB.getBinaryOutputStream();
    System.out.println("The Control 9");
    // Open the sample file as a stream for insertion into the BLOB column
    File l_blobvariable = new File(s_blobvariable);
    InputStream l_sampleFileStream=new FileInputStream(l_blobvariable);
    System.out.println("The Control 10");
    // Buffer to hold chunks of data to being written to the BLOB.
    // In Oracle8.1.5 JDBC drivers a method getBufferSize() is available
    // in the BLOB class, that returns the optimal buffer size
    byte[] l_buffer = new byte[10* 1024];
    System.out.println("The Control 11");
    // Read a chunk of data from the sample file input stream, and write the
    // chunk to the BLOB column output stream. Repeat till file has been
    // fully read.
    int l_nread = 0; // Number of bytes read
    while ((l_nread= l_sampleFileStream.read(l_buffer)) != -1) // Read from file
    l_blobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
    System.out.println("The Control 12");
    // Close both streams
    l_sampleFileStream.close();
    l_blobOutputStream.close();
    System.out.println("Done Loading sample files");
    System.out.println("\nRetrieving and displaying sample files..");
    // Retrieve and display the LOB data just inserted
    drawBLOB(l_mapBLOB,p_doc_name,p_doc_type);
    //System.out.println("Done loading and displaying LOB data");
    } //if statement closes here
    l_lobDetails.close();// Close Result Set and statement
    l_stmt.close();
    } catch (Exception ex)
    { // Trap       SQL errors
    System.out.println("Error loading sample files for the selected airport");
    System.out.println("\n"+ex.toString());
    }//Method closes here
    * Retrieve the BLOB data from input BLOB column into a local file,
    * and draws the image. The file type needs to be added here
    public void drawBLOB(BLOB p_blob, String p_doc_name,String p_doc_type) {
    //String fileType this should be passed at some point to ensure that the file gets the right extension
    try {
    // Open a stream to read the BLOB data
    InputStream l_blobStream = p_blob.getBinaryStream();
    // Open a file stream to save the BLOB data
    FileOutputStream l_fileOutStream = new FileOutputStream(p_doc_name+"."+p_doc_type);
    // Read from the BLOB data input stream, and write to the file output
    // stream
    byte[] l_buffer = new byte[10]; // buffer holding bytes to be transferred
    int l_nbytes = 0; // Number of bytes read
    while ((l_nbytes = l_blobStream.read(l_buffer)) != -1) // Read from BLOB stream
    l_fileOutStream.write(l_buffer,0,l_nbytes); // Write to file stream
    // Flush and close the streams
    l_fileOutStream.flush();
    l_fileOutStream.close();
    l_blobStream.close();
    //m_GUI.drawMap(p_doc_name,p_doc_type);
    // Draw retrieved image to GUI
    drawMap(p_doc_name,p_doc_type);
    } catch (Exception ex) { // Trap SQL and IO errors
    System.out.println("Error in retrieving and drawing map for selected airport");
    System.out.println("\n"+ex.toString());
    * Create a label from the image filepassed, add the label to the image area
    This part will have to be modified majorly
    public void drawMap(String p_doc_name,String p_doc_type) {
    //Refer to SIRExtOpen.java
    Runtime r = Runtime.getRuntime();
    Process p = null;
    if (p_doc_type.equals("html")&#0124; &#0124;p_doc_type.equals("htm"))
    try{
    p = r.exec( "C:\\Program Files\\Internet Explorer\\Iexplore.EXE " + p_doc_name);
    //repaint();
    p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    if(p_doc_type.equals("txt")&#0124; &#0124; p_doc_type.equals("sql")&#0124; &#0124; p_doc_type.equals("java"))
    try
    p = r.exec( "C:\\WINDOWS\\notepad.EXE " + p_doc_name); p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of txt , sql , java if
    if(p_doc_type.equals("xls"))
    try
    p = r.exec( "C:\\Program Files\\Microsoft Office\\Office\\excel.EXE " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of xls if
    if(p_doc_type.equals("fmb"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of fmb if
    if(p_doc_type.equals("doc"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of doc if
    if(p_doc_type.equals("mpp"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of mpp if
    //Here you can write a statement for deleting the file in the root directory once the file is opened using any editor
    }//end of method
    }//This is the class closing
    * This method is called when a row is selected from the combo.
    * It checks if there exists data in DOC_DETAIL for the selected
    * file. If there exists data, it calls drawBLOB and writeCLOB to
    * display the data
    /*public void fileSelected(String p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    try {
    System.out.println("Retrieving LOB details for selected file..");
    // Create a SQL statement
    Statement l_stmt = m_connection.createStatement();
    // Query DOC_DETAILS for the selected file
    java.sql.ResultSet l_lobDetails = l_stmt.executeQuery(
    "SELECT ACTUAL_DOC FROM DOC_DETAILS "+
    "WHERE DOC_MAS_SR_NO='"+p_doc_mas_sr_no+"'");
    // Check if LOB columns exist
    if (l_lobDetails.next()) {
    // LOB details exist
    // Display airport map and suggestion book (LOB details)
    drawBLOB(l_lobDetails.getBlob(1),p_doc_name,p_doc_type);
    //lobs.drawBLOB(((OracleResultSet)l_lobDetails).getBLOB(1),p_doc_name,p_doc_type);
    //Should this be like this
    System.out.println("Done retrieving and displaying LOB details");
    } else {
    // No LOB details
    // m_GUI.m_loadButton.setEnabled(true);
    //TO BE CHECKED OUT LATER m_loadButton This is a button in the form
    System.out.println("No airport map and suggestion book exist for selected airport");
    System.out.println("\nPress <Load Sample2 Files> to load LOB details");
    l_lobDetails.close();
    l_stmt.close();
    } catch (Exception ex) { // Trap SQL errors
    System.out.println("Error retrieving LOB Details for the selected airport");
    System.out.println(ex.toString());

    You are probably better off using BLOBs rather than BFILEs. The main reason for this is that with BLOBs data integrity between file and its meta data in the database are managed and protected by the RDBMS. BFILEs are useful for legacy systems where the files already exist in some form of meaningful and managed structure that needs to be preserved.
    There is a down side to BLOBs and that is performance - BLOBs are relatively slow to load into the database. However, its not too bad and the performance of extracting BLOBs out from the database is quite reasonable the bottleneck is more likely to be your LAN.
    In order to use BLOBs it is important to have the right class libraries involved. For BLOBs you must use the classes12.zip (supplied with the database) for JDBC2 support and furthermore put this class high up the list of class libraries if you do not you may find that your code compiles but raises a runtime exception about invalid data types; this is because the wrong definition of the Blob class is being picked up.
    Assuming that you are using BLOBs then the following describes the techniques for storing files as BLOBs in an Oracle database.
    LOADING BLOBS
    Assuming that you have a table with a BLOB column in it then to load a BLOB you must first create the record containing the BLOB by inserting a row into your table with the value of the BLOB column set to EMPTY_BLOB( ) (PL/SQL built in):
    INSERT INTO tablex( col1, col2, colBLOB )
    VALUES( val1, val2, EMPTY_BLOB() )
    Then you must row lock this record and obtain the LOB locator for the BLOB just created:
    stmt = connection.createStatement();
    query = "SELECT colBLOB FROM tablex WHERE ... FOR UPDATE OF colBLOB";
    ResultSet lockLOBSet = stmt.executeQuery(query);
    At this point you should be able to use lockLOBSet.getBlob(1) to create a binary stream to load the BLOB directly into the database. Under Java Developer 2 I could never get this to work and havent tried since with Java Developer 3. Instead I used the PL/SQL DBMS_LOB package and did it using JDBC; this assumes that the file has been loaded into a buffer binaryFile and note that the maximum chunk size that dbms_lob.write can be called with is 32K:
    blobLoc = lockLOBSet.getBlob(1);
    while(amountWritten < fileSize)
    if ((amountWritten + writeAmount) <= fileSize)
    writeAmount = 32000;
    else
    writeAmount = fileSize - amountWritten;
    System.arraycopy(binaryFile, amountWritten, buffer, 0, writeAmount);
    CallableStatement cstmt =
    connection.prepareCall("{call dbms_lob.write(?, ?, ?, ?)}");
    cstmt.setBlob(1, blobLoc);
    cstmt.setLong(2, writeAmount);
    cstmt.setLong(3, amountWritten + 1);
    cstmt.setBytes(4, buffer);
    cstmt.execute();
    cstmt.close();
    amountWritten = amountWritten + writeAmount;
    EXTRACTING BLOBS
    Binary streams do work when it comes to reading BLOBs out of the database so things are a whole lot simpler probably worth trying it with loading BLOBs now as well.
    ResultSet queryLOBSet = statement.executeQuery(query);
    if(queryLOBSet.next())
    lobSize = queryLOBSet.getInt(1);
    blobLoc = queryLOBSet.getBlob(2);
    BufferedInputStream bi;
    blobBuffer = new byte[lobSize];
    bi = new BufferedInputStream(blobLoc.getBinaryStream());
    amountRead = bi.read(blobBuffer);
    bi.close();
    Regards,
    Bob
    null

  • Please HELP!!! I try to insert BLOB to Oracle

    Please help, I try to insert BLOB to Oracle.
    Here is my sample code. Basically what i tried to do is to to try to insert an image file to Oracle.
    But it did not work. If you have a sample code that works, please give me.
    Thanks,
    Tom
    try
    out.println ("Done");
    dbCon=trans.getConnection();
    dbCon.setAutoCommit(false);
    stmt1.execute ("update emorytest.PHYSICIANFOTO set FOTO=empty_blob() where name = 'foobar'");
    stmt = dbCon.prepareCall("SELECT FOTO from emorytest.PHYSICIANFOTO where name='foobar' for update");
    stmt.execute();
    rset = (OracleResultSet)stmt.getResultSet();
    rset.next();
    BLOB bdata = rset.getBLOB("test.jpg");
    os = bdata.getBinaryOutputStream();
    os.write(bdata);
    os.flush();
    os.close();
    dbCon.commit();
    dbCon.close();
    catch (Exception ex)
    ex.printStackTrace();

    Well, the obvious problem is that your "getBLOB" call ought to access the field by the field name "FOTO" not by a file name. Then you need to open an FileInputStream for the image before copying it to the blob's output stream.
    In my opinion BLOB and CLOB handling is jdbc is a confusing mess.

  • Inserting blob data into database

    Hello everybody,
    I need insert blob data into database. that data i need to get from form
    can i use request.getParameter(""); for getting that file.
    Plz help how to get data from form to servlet and through callablestatement i need to insert into database.
    regards,
    Anil

    Hi,
    1) first create a form with file element
    first.jsp
    <form action="GetData" enctype="multipart/form-data" method="post">
    <input type="file" name="datafile" size="40">
    <input type="submit" value="Send">
    <input type="reset" name="Reset" value="Cancel">
    </form>
    GetData.java
    // servlet file
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter out = response.getWriter();
    try {
    System.setProperty( "jdbc.drivers", "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    con = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JAVATEAM;SelectMethod=cursor;User=sa;Password=urpassword" );
    PreparedStatement pst = con.prepareStatement("insert into uploads(binaryfile) values(?)");
    FileInputStream fis=new FileInputStream(request.getParameter ( "datafile" ) );
    byte[] b= new byte[fis.available()+1];
    fis.read(b);
    pst.setBytes(1,b);
    pst.executeUpdate();
    pst.close();
    con.close();
    catch(SQLException e)
    out.println ( e);
    catch (ClassNotFoundException e)
    out.println( e );
    }Here in doPost(), i create preparedstatement,
    now you to create one procedure for insert
    and by using callable statement you just call that procedure and pass this byte b as arguments,
    now its in your hands
    my idea is over.

  • Inserting Blob in PL/SQL using select from other table

    Oracle 11.1.7.0:
    I am trying to insert blob column as defined below but not able to. Is this the right way of inserting blobs?
    set serveroutput on
    spool a.dat
    DECLARE
    BEGIN
      for i in 1..2
      loop
         for j in  (select r_payload                      
                       from fp_data where payload_id=331525112)
         loop
           EXECUTE IMMEDIATE 'insert into fp_data (r_payload) values ( ' || j.r_payload || ')';
        end loop;
      end loop;
      rollback;
    END;
    exit;

    BLOB work same a CLOB
    SQL> @clob
    SQL> drop table toto;
    SQL> create table toto (
      2    A  VARCHAR2 (30)  NOT NULL,
      3    B  VARCHAR2 (30)  NOT NULL,
      4    C  clob default empty_clob()
      5  )
      6        lob(c) store as toto_name_lo(disable storage in row)
      7  ;
    SQL>
    SQL> set feedback off
    SQL> set timing on;
    SQL> prompt
    SQL> prompt Insert lob with enabled storage in row:
    Insert lob with enabled storage in row:
    SQL> insert into toto (a, b, c)
      2  select owner a, object_name b, owner || ' ' || object_name c from all_objects
      3  where rownum < 10
      4  ;
    Elapsed: 00:00:00.51
    SQL> set timing off;
    SQL> select a,b from toto;
    A                      B
    SYS                      ICOL$
    SYS                      I_USER1
    SYS                      CON$
    SYS                      UNDO$
    SYS                      C_COBJ#
    SYS                      I_OBJ#
    SYS                      PROXY_ROLE_DATA$
    A                      B
    SYS                      I_IND1
    SYS                      I_CDEF2
    SQL> drop   table fp_data;
    SQL> create table fp_data (r_payload clob);
    SQL> insert into fp_data select c from toto where a = 'SYS'     AND B = 'I_IND1';
    SQL> select count(*) from fp_data;
      COUNT(*)
          1no need for PL/SQL

  • SQLite3 and BlobsI am having trouble learning how insert blobs into SQLite

    I am having trouble learning how insert blobs into SQLite for the iphone. Is there a way to insert a blob into sqlite3 from the command line? I know it was possible with sql using
    INSERT INTO temponly(name , pic) values( 'velan',
    load_file('e:/mysql/images/Click.gif')) ;
    but I don't think load_file is supported on sqlite.
    Also, I need to insert the blobs from my iphone app. I saw a C program called eatblob.c which goes through the following just to INSERT a blob into sqlite
    1. read the jpeg image file into memory , doing appropriate malloc based on size
    2. prepare an sqlite statement with ? values
    3. bind the malloc'd memory to the ?
    4. execute an sqlite step
    etc. etc. etc....
    This is quite a bit of work just to do an INSERT ???
    The reason I'm doing this is my iphone app has a lot of tiny (20x20) images that get downloaded to the phone periodically from the server. Plus, there are a number of images that come loaded with the application. I was going to save all of these in SQLite. So, I need the command line tool to load up the initial images that come with the app, then I need code to download the images from the server and load them into the database. Of course, reading them out is necessary!
    Please help if you can!? Its late..and I'm blurry eyed from googling SQLIte3 blobs...

    Thank you for your quick reply Liam! You know, I checked the web forms list when I got that error message and the form isn't there. I was having trouble the other day when another of my forms kept getting deleted.
    Sorry if this is a stupid question (I'm a BC newbie) but I want to be sure so I can get this project finished... The proper workflow would be to create this form myself in Web Forms then insert it into the Registration - Buy template using the modules toolbox?
    Thanks to you I may get this done on time still... if my PayPal set up works

  • Single record insert performance problems

    Hi,
    we have on production environment a Java based application that makes aprox 40.000 single record Inserts per hour into a table.
    We ha traced the performance of this Insert and the medium time is 3ms, that is ok. Our Java architecture is based in Websphere Application Server and we access to Oracle 10g through a WAS datasource.
    But we have detected that 3 or 4 times a day, during aprox 30 seconds, the Java service is not able to make any insertion in that table. And suddenly it makes all the "queued inserts" in only 1 second. That "pause" in the insertion cause problems of navigation because is the top layer there is a web application.
    We are sure that is not a problem with the WAS or the Java code. We are sure that is a problem with the Oracle configuration, or some tunning action for this kind of applications that we don´t know. We first thought it could be a problem with a sequence field in the table. Also, a problem when occurs the change of the redo log. But we've checked it with our DBA and this is not the problem.
    Has anybody any idea of what could be the origin of this extrange behaviour?
    Thanks a lot in advance.
    Jose.

    There are a couple of things you'd need to look at to diagnose this - As Joe says it's not really a JDBC issue from what we know.
    I've seen issues with Oracle's automatic SGA resizing causing sporadic latency in OLTP systems. Another suspect would be log file sync wait events, which are associated with commits. Don't discount the impact of well meaning people using tools like TOAD to query the DB - they can sometimes cause more harm than good.
    Right now I'd suggest you run AWR at 10 minute intervals and compare reports from when you had your problem with a time when you didn't.

  • Inserting BLOBs Programmatically

    Is it possible to insert BLOBs programmatically?
    http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/inserting.html
    has details on this, but it appears to be at odds with the "empty_blob()" mechanism used by oracle, which requires an explicit insert statement.
    Thanks,
    Sanjay

    Although jdbc can't immediately see how the Blob/Clob needs to be implemented the database implementors should. The sequence should be as you suggest: create a new blob, write the data to it then store the OID in the database with a PreparedStatement.
    Because the Blob needs to be database implementation specific new Blobs should be created from the Connection object. In the typical case writing to the Blob should write straight to the database. Copying block values from one record to another should just involve copying the OID.
    As I read the Blob class description it should mean that the actual data isn't moved to or from the client unless you open a stream on it.
    Looking at the postgres implementation source it's pretty crude, in fact whereas retrieving a blob works as I suggested; no reads from the database until you open the stream, when you write the blob back to the database it's creating a new OID every time. I'd assumed it would retrieve the OID from the Blob you passed to PreparedStatment.setBlob actually it creates a new OID and copies the data byte by byte (icky).
    Looks, in fact, as if I can create a fake Blob with nothing but a getBinaryStream method.
    setBinaryStream/setAsciiStream doesn't work properly because it seems to decide whether the field is a blob purely based on the implementation version of postgres, without regard for the field type. (I suppose you can't judge the field type in a PreparedStatement).

  • Problem inserting Blob through Oracle 9iAs

    Hai Everybody,
    I got a unique problem , i am trying to insert a blob object to the blob column. This is working fine when i am using JDeveloper 9.0.3 , but when i am using the same on 9iAS , the data is not evening inserting to the database. Please can any body help me how to solve this problem.
    This is the code used to insert into the database.
    if (resSet.next()) {
    oracle.sql.BLOB bCol = ((OracleResultSet)resSet).getBLOB(1);
    blobOutputStream = bCol.getBinaryOutputStream();
    byte[] bBuffer = new byte[bCol.getBufferSize()];
    int intBytesRead = 0;
    ByteArrayInputStream fis = new ByteArrayInputStream(byteValues);
    ErrorLog.log(" before the while loop ");
    while ((intBytesRead = fis.read(bBuffer)) != -1) {
    blobOutputStream.write(bBuffer,0,intBytesRead);
    blobOutputStream.close();
    // i am commiting the connection here
    conn.commit();
    conn.setAutoCommit(true);

    Hi !, you can find response of this answer in Oracle forums...
    http://forums.oracle.com/forums/forum.jsp?forum=99

  • Sql server bulk insert blob filename parameter

    My problem SQL script:
    declare @filepath varchar(100)
    set @filepath = 'E:\foto\1.jpg'
    INSERT INTO [dbo].[MsQuestions] ([TestCategoryID], [LevelID], [TestTypeID], [QuestionText], [QuestionImg])
    select  1 , 1, 8, 'data gambar',BulkColumn FROM OPENROWSET(BULK   @filepath , SINGLE_BLOB)
    thanks.
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%
    string sConn = @"server=.; database=OnlineTesting; Integrated Security=True";
    SqlConnection objConn = new SqlConnection(sConn);
    objConn.Open();
    string sTSQL = "exec sp_filenamea";
    SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
    objCmd.CommandType = CommandType.Text;
    SqlDataReader dr = objCmd.ExecuteReader();
    dr.Read();
    Response.BinaryWrite((byte[])dr["QuestionImg"]);
    objConn.Close();
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title>Exec SP</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
    </body>
    </html>

    Perhaps this 
    http://dimantdatabasesolutions.blogspot.co.il/2009/05/how-to-uploadmodify-more-than-one-blob.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Blob problem (Image storing or Currupted )

    AOA!
    I am working as a developer in a companey. we made a database for HRMS. In this database there is a table EMPLOYEE with a column PICTURE of type BLOB. We were using oracle 8i initially but when we migrate to oracle 9i, we are facing a problem in image storing. The situation is, database showing ur previously stored images (those have stored in oracle 8i) but when we save a new image in that table or any other table it seams to be saved but cannot retrived. I mean when we issue a query
    SELECT EMP_ID FROM EMPLOYEE WHERE PICTURE IS NOT NULL;
    It shows the new inserted records too (thats shows us that picture has been inserted) but when we issue query from a forms6i application it didnt show any image. In case of report, when we try to query a record which newly inserted with image, it says some thing like REPORT IS UNABLE TO SHOW IMAGE FORMATE etc.
    The situation is for all table and all schema which is indicating us may be it is some thing due to oracle 9i headen technique or due to miss managment by us. we dont have DBA in our companey.
    Please help us in this regard. We will be thankfull to you.
    Usman Rana
    Dont reply to above mantioned email my actual email account is [email protected]

    hello,
    these are very specific questions about forms and reports functionality. i would suggest you publish this
    question in the forms and reports forum.
    regards,
    philipp

  • BLOB problem (image storing or image curruption)

    AOA!
    I am working as a developer in a companey. we made a database for HRMS. In this database there is a table EMPLOYEE with a column PICTURE of type BLOB. We were using oracle 8i initially but when we migrate to oracle 9i, we are facing a problem in image storing. The situation is, database showing ur previously stored images (those have stored in oracle 8i) but when we save a new image in that table or any other table it seams to be saved but cannot retrived. I mean when we issue a query
    SELECT EMP_ID FROM EMPLOYEE WHERE PICTURE IS NOT NULL;
    It shows the new inserted records too (thats shows us that picture has been inserted) but when we issue query from a forms6i application it didnt show any image. In case of report, when we try to query a record which newly inserted with image, it says some thing like REPORT IS UNABLE TO SHOW IMAGE FORMATE etc.
    The situation is for all table and all schema which is indicating us may be it is some thing due to oracle 9i headen technique or due to miss managment by us. we dont have DBA in our companey.
    Please help us in this regard. We will be thankfull to you.
    Usman Rana
    Dont reply to above mantioned email my actual email account is [email protected]

    hello,
    these are very specific questions about forms and reports functionality. i would suggest you publish this
    question in the forms and reports forum.
    regards,
    philipp

  • Blob Problem (storing Images)

    AOA!
    I am working as a developer in a companey. we made a database for HRMS. In this database there is a table EMPLOYEE with a column PICTURE of type BLOB. We were using oracle 8i initially but when we migrate to oracle 9i, we are facing a problem in image storing. The situation is, database showing ur previously stored images (those have stored in oracle 8i) but when we save a new image in that table or any other table it seams to be saved but cannot retrived. I mean when we issue a query
    SELECT EMP_ID FROM EMPLOYEE WHERE PICTURE IS NOT NULL;
    It shows the new inserted records too (thats shows us that picture has been inserted) but when we issue query from a forms6i application it didnt show any image. In case of report, when we try to query a record which newly inserted with image, it says some thing like REPORT IS UNABLE TO SHOW IMAGE FORMATE etc.
    The situation is for all table and all schema which is indicating us may be it is some thing due to oracle 9i headen technique or due to miss managment by us. we dont have DBA in our companey.
    Please help us in this regard. We will be thankfull to you.
    Usman Rana
    Dont reply to above mantioned email my actual email account is [email protected]

    I think that both your SQL is wrong and your intended use is wrong. According to the SQL reference, the following seems to be a simplified definition that seems to match what you're trying to do. UPDATE &lt;table&gt; SET &lt;column&gt; = &lt;expr&gt;. So PROPERTIES should be a &lt;table&gt; of some kind and X should be a &lt;column&gt; of that table. This changes your PreparedStatement to *"UPDATE PROPERTIES SET X = ? WHERE NAME = ?"* Then you can do ps.setBlob(1, b) and ps.setString(2, ...). Because your statement is DML you must do ps.executeUpdate(). So your code might look something like this.
    Blob b = ...;
    String x = ...;
    ps = c.prepareStatement("UPDATE PROPERTIES SET X = ? WHERE NAME = ?");
    ps.setBlob(1, b);
    ps.setString(2, x);
    int i = ps.executeUpdate();
    The executeUpdate() returns the row count (i.e. number of rows) of your DML statement. Try that and see if it helps.

  • Blob Problem (image not store or currup in database)

    AOA!
    I am working as a developer in a companey. we made a database for HRMS. In this database there is a table EMPLOYEE with a column PICTURE of type BLOB. We were using oracle 8i initially but when we migrate to oracle 9i, we are facing a problem in image storing. The situation is, database showing ur previously stored images (those have stored in oracle 8i) but when we save a new image in that table or any other table it seams to be saved but cannot retrived. I mean when we issue a query
    SELECT EMP_ID FROM EMPLOYEE WHERE PICTURE IS NOT NULL;
    It shows the new inserted records too (thats shows us that picture has been inserted) but when we issue query from a forms6i application it didnt show any image. In case of report, when we try to query a record which newly inserted with image, it says some thing like REPORT IS UNABLE TO SHOW IMAGE FORMATE etc.
    The situation is for all table and all schema which is indicating us may be it is some thing due to oracle 9i headen technique or due to miss managment by us. we dont have DBA in our companey.
    Please help us in this regard. We will be thankfull to you.
    Usman Rana

    I have a mistake , the right code is :
    <listobject:create name="mylist" columns="field,value" />
         <listobject:addrow name="mylist">
              <listobject:argument name="field" value="historyAttr1" />
              <listobject:argument name="value" value="1234" />
         </listobject:addrow>

Maybe you are looking for

  • Adding Artwork Corrupts Songs

    This doesn't happen every time, but it seems to happen more frequently than not: Sometimes when I burn a CD to iTunes and add album artwork, a previously fine track will no longer play correctly. The song will be fine, then I'll add artwork, and when

  • Dynamic Webservice Target URL

    I am using Crystal Reports for Eclipse to serve up some reports for my web application. Currently, I am using JDBC datasources in which I am changing the datasource at runtime in a CrystalReportViewer where I also set some report parameters for every

  • Setting app restrictions messes with the desktop?

    hi there, i am running a 10.5.6 server in a 10.5.7 client computer lab environment. i am trying to restrict students from launching their own apps (many seem to want to torrent in the labs...). when i set group restrictions to only allow apps in spec

  • Migrating Online Email Subfolders to Outlook 2007

    Hoping somebody has gone through this before and can assist. Trying to move all my email and folders from the BT Online Mail into Outlook. Finally managed to get all my mail synchronised and off the BT Server, but Subfolders with emails have not been

  • ITunes 10 poor audio quality

    After upgrading to iTunes 10, I noticed when playing music from my library that the audio quality is significantly lower than previously with iTunes 9.x. The audio quality sounds muffled and distorted. I found this thread in the Windows section, but