Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Blob type update

Posted on 2002-03-04
4
Medium Priority
?
310 Views
Last Modified: 2010-04-01
I don't understand why.... I can't seems to update blob field type. Is there a special type of update for blob type? I will get the value from the form, typecast it to string then update the db. All fields can be updated except the blob type field....
0
Comment
Question by:yan_er04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6841748
how are you trying to update it?

Are you inserting it back as binary?

if you have it as a string update it passing stringvarname.getBytes() as the value.

CJ
0
 
LVL 6

Accepted Solution

by:
kotan earned 120 total points
ID: 6849440
Here is the example of insert BLOB object into oracle db

public void insertFile(Connection conn ,int idocId, byte[] bydata1) {
  try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@XXXserver:1521:database", "scott", "tiger");

    conn.setAutoCommit(false);
    stmt = conn.createStatement();
    stmt.execute("INSERT into " + SDocData +" values ('"              + idocId + "', EMPTY_BLOB()) ");
    rs = stmt.executeQuery("select * from "+ SDocData + "where doc_id = '" + idocId + "' for update of file_data");

    while(rs.next()) {
      blob = (oracle.sql.BLOB)rs.getObject(2);
    }

    System.out.println(" Blob length before insert " + blob.length());
    java.io.OutputStream os = ((oracle.sql.BLOB)blob).getBinaryOutputStream();

    os.write(bydata1);
    os.flush();
    os.close();

    System.out.println("Blob length in the database " + blob.length());
    OraclePreparedStatement ops =(OraclePreparedStatement)conn.prepareStatement ("update Doc_Data set file_data=? where  " +" doc_id = '" + idocId + "'");
    ops.setBLOB(1, blob);
    ops.execute();
  } catch (IOException e) {
    e.printStackTrace();
  }
}
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9552545
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

"Accept kotan's comment as answer."
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Kuldeepchaturvedi
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question