This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes About setBLOb & getBlob Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "About setBLOb & getBlob" Watch "About setBLOb & getBlob" New topic
Author

About setBLOb & getBlob

shruty sharma
Greenhorn

Joined: Dec 25, 2008
Posts: 4
Hi!!

I want to insert byte array in database schema as follows:
table message
{
msgid number(5),
messagevalue BLOB
};

I have done this in following way But I am getting NULL pointer exception.

//byte[] msgval .. contains byte values like 49 50 53 etc.

Blob msg;
msg.setBytes(1,msgval);
// for prepared statement I have used st2.setBlob(4,msg);
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It´s hard to help without knowing the details.
http://faq.javaranch.com/java/TellTheDetails
 
jQuery in Action, 3rd edition
 
subject: About setBLOb & getBlob
 
It's not a secret anymore!