• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC3 - How to write in bytea

 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I used JDBC3 driver for inserting into postgresql 7.3. The field's datatype is bytea. When i tried to insert more than 2MB file, it is hanging. Can somebody give me the full working code for inserting bigger files like 40MB into bytea?
Thanks in advance,
Sankar
 
Shiv Sidhaarth
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am placing the code here :
UnitForm uni - javabean
InputStream fstream=null;
fstream=uni.getIstream();
int c=fstream.available();
String query = "INSERT INTO elunit (unitid, domainid, unitname, unittype, "+
"description, content_type, filename, content) "+
"VALUES (nextval('elms_seq_unit'),?,?,?,?,?,?,?) ";
ps = con.prepareStatement(query);
ps.setInt(1,Integer.parseInt(uni.getDomainid()));
ps.setString(2,uni.getUnitname());
ps.setString(3,uni.getUnittype());
ps.setString(4,uni.getDescription());
ps.setString(5,uni.getContenttype());
ps.setString(6,uni.getFilename());
ps.setBinaryStream(7, fstream, c);
ps.executeUpdate();
ps.close();

Pleaze help,
Sankar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic