[ http://issues.apache.org/jira/browse/DERBY-2070?page=all ]

Andrew McIntyre resolved DERBY-2070.
------------------------------------

    Resolution: Invalid

JIRA should be used to file bugs or request features. Please use the derby-user 
mailing list for general questions about Derby. For information on using the 
Derby mailing lists, see: http://db.apache.org/derby/derby_mail.html

> 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

        

Reply via email to