• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Document doc => xml => blob at mySQL

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm trying to write Document object content to mySQL as xml file stored as blog.But I guess my code stores it as Document file stored as blog.

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeObject(doc);
out.close();
String query = "insert into mysql1.fpmltable(id,xml) values (?,?)";
PreparedStatement pstmt = con.prepareStatement(query);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
pstmt.setString(1,"AD98");
pstmt.setBinaryStream(2, bais, bytes.length);
Any Idea how to write
cahnge Document to xml file then storing it mysql as blob?
Hussain
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to serialize the document to XML and then store it in CLOB.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!