| 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
|