• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC3 - How to write in bytea

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic