public inbox for [email protected]
help / color / mirror / Atom feedSubject: [Pljava-dev] Issue with xml column
Date: Tue, 30 Dec 2014 05:45:35 +0000
Message-ID: <4F3EFA2C9B56AD47AF2FCD3C7FD14A8701159928BF@VS1-Exchange.blr-zenithsoft.net> (raw)
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;
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Subject: Re: [Pljava-dev] Issue with xml column
In-Reply-To: <4F3EFA2C9B56AD47AF2FCD3C7FD14A8701159928BF@VS1-Exchange.blr-zenithsoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox