Lists: | pljava-dev |
---|
From: | Anilk at zenithsoft(dot)com (Anil K Krishna) |
---|---|
To: | |
Subject: | [Pljava-dev] Issue with xml column |
Date: | 2014-12-30 05:45:35 |
Message-ID: | 4F3EFA2C9B56AD47AF2FCD3C7FD14A8701159928BF@VS1-Exchange.blr-zenithsoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pljava-dev |
Hi,
I am using PL java to insert data into the postgres sql database table. One of my tables has column of type XML.
I am inserting data using prepared statement as shown below
String sql = "Insert into company (name, address, phone) values (? , ?::xml, ?);
String xmlData = "<MAIN><DATA><ADDRESS> <STREET>11</STREET></ADDRESS></DATA> </MAIN>";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,"TEST");
pstmt.setString(2, xmlData);
pstmt.setString(3,"001456766");
pstmt.executeUpdate();
However when the above code is executed it inserting the xml column has with data having all the new characters as shown below
ADDRESS column value in db is
<MAIN>\n\t<DATA>\n\t<ADDRESS>\n\t <STREET>11</STREET>\n\t </ADDRESS>\n\t </DATA>\n\t </MAIN>
I would like to know why is this \n\t is inserted is there a way to avoid it.
Also if I use the code below in PL java I am getting exception
SQLXML sqlXML = connection.createSQLXML();
sqlXML.setString(xmlData);
pstmt.setSQLXML(2, sqlXML);
Thanks
Anil Kumar Krishna
Anil Kumar Krishna | Sr. Project Manager
Zenith Software Limited
Phone: +91 80 25525690
Mobile: +91 9972585161
Email: anilk at zenithsoft.com<mailto:anilk at zenithsoft.com> URL: www.zenithsoft.com<http://www.zenithsoft.com>
________________________________
DISCLAIMER: The information contained in this e-mail is confidential and is intended for use by the addressee only. Any views or opinions presented in this e-mail are solely those of the author and may not necessarily reflect the opinions of Zenith Software Limited. Any unauthorised dissemination or copying of this e-mail and any use or disclosure of information contained in it, is strictly prohibited and may be illegal. Please let us know immediately by return e-mail, if the e-mail has been sent to you in error.
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20141230/bfe9a595/attachment.html>