Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 68310 invoked from network); 10 Nov 2006 11:25:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2006 11:24:59 -0000 Received: (qmail 29289 invoked by uid 500); 10 Nov 2006 11:25:10 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 29253 invoked by uid 500); 10 Nov 2006 11:25:09 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 29244 invoked by uid 99); 10 Nov 2006 11:25:09 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 03:25:09 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 03:24:58 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id ACE0E7142F5 for ; Fri, 10 Nov 2006 03:24:37 -0800 (PST) Message-ID: <21789896.1163157877678.JavaMail.jira@brutus> Date: Fri, 10 Nov 2006 03:24:37 -0800 (PST) From: "Anurag Shekhar (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-2070) Is there a way to initialise a BLOB in derby, and how to insert a document object in Derby In-Reply-To: <10517410.1163139097014.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/DERBY-2070?page=comments#action_12448705 ] Anurag Shekhar commented on DERBY-2070: --------------------------------------- org.w3c.dom.Document doesn't extends from Serializable so it can't be written into stream unless the implementation class is extending from the same. In case of Crimson the implementation doesn't appears to be be extending from it either. Hence the java.io.NotSerializableException. So you may have to either insert the XML file as text stream into blob or clob fields. If you are using derby 10.2 you can look into XML data type and functions related to that to see if it meets your requirements. here is the link of ref. manual if you want to know more about XML functions available in derby http://db.apache.org/derby/docs/10.2/ref/ > Is there a way to initialise a BLOB in derby, and how to insert a document object in Derby > ------------------------------------------------------------------------------------------ > > Key: DERBY-2070 > URL: http://issues.apache.org/jira/browse/DERBY-2070 > Project: Derby > Issue Type: Bug > Environment: Windows 98,Derby ,JAVA. > Reporter: kishorevodnala > > I have a problem while inserting an XML document object into a BLOB column in Derby database. > Could you please help me out in resolving this problem. > Note:there is empty_blob function in oracle for initialising a BLOB.Is there anything in derby for initialising a BLOB like in oracle. > Following is the sample code. > //creating a DOM object for a xml file and storing this object into the BLOB column in the database using streams. > class exdom > { > public static void main(String ss[]) > { > Document pdxDOM =buildDocument();//creating a DOM object for xml file > serializePDXDOMToDB(pdxDOM); //storing this object into the BLOB column in the database using streams > } > public static Document buildDocument() { > Document document = null; > try { > DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); > DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); > document = documentBuilder.parse(new File("d:\\sample.xml")); > } catch (Exception e) {e.printStackTrace();} > > return document; > } > public static void serializePDXDOMToDB(Document obj) { > Connection conn = null; > PreparedStatement ps = null; > ResultSet rs = null; > String query = "insert into ex9(bl) values(?) " ; > > try { > Class.forName("org.apache.derby.jdbc.ClientDriver"); > String url="jdbc:derby://s104f50:1527/example;create=true"; > conn=DriverManager.getConnection(url); > > ps = conn.prepareStatement(query); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > ObjectOutputStream oout = new ObjectOutputStream(baos); > oout.writeObject(obj); > oout.close(); > > ps.setBytes(1, baos.toByteArray()); > ps.execute(); > > > > }catch(Exception e){e.printStackTrace();} > } > } > > Following is the exception that occured while execution: > java.io.NotSerializableException: org.apache.crimson.tree.XmlDocument > at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054) > at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java > :1330) > at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:13 > 02) > at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.jav > a:1245) > at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052) > at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) > at exdom.serializePDXDOMToDB(exdom.java:42) > at exdom.main(exdom.java:11) > //this code is working fine for String and Integer objects but getting an Exception while trying to insert an XML Document object. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira