For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2005 > retrieve XML from database









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author retrieve XML from database
sarath

2005-06-02, 3:59 pm

I have inserted an xml to the mySQL database as a BLOB type using JDBC
and java, with the code,

Statement stat=con.createStatement();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamResult result = new StreamResult(baos);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);

String query = "insert into policy(id,type,xml) values
(?,?,?)";
PreparedStatement pstmt = con.prepareStatement(query);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
pstmt.setInt(1,0);
pstmt.setString(2,"Description");
pstmt.setBinaryStream(3, bais, bytes.length);
pstmt.executeUpdate();

how can i retrieve the same from the database, so that i can display it
or output to a file..

please help..thanks in advance

sarath

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com