Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I insert an XML document in PostgreSQL in Java?
    primarykey
    data
    text
    <p>I have a table in Postgresql </p> <pre><code>DROP TABLE xml_docs; CREATE TABLE xml_docs( id serial PRIMARY KEY, cad_number character(50), gkuzu_name character(50), gkuzu xml, rreq_name character(50), rreq xml ) </code></pre> <p>I use JDBC for data base connection. And i want to insert whole xml document in table.<br> How can i make this?</p> <p><strong>UPDATE</strong></p> <p>Okey. i try </p> <pre><code> String sql = "INSERT INTO xml_docs(cad_number,gkuzu_name,gkuzu,rreq_name,rreq) VALUES(?,?,?,?,?)"; PreparedStatement stmt = ce.prepareStatement(sql); stmt.setString(1, "11:33:5464563"); stmt.setString(2, xml_gkuzu.getName()); stmt.setString(3, xml_gkuzu.toString()); stmt.setString(4, xml_rreq.getName()); stmt.setString(5, xml_rreq.toString()); stmt.executeQuery(); ce.close(); se.close(); </code></pre> <p>and get exeption </p> <pre><code>Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "gkuzu" is of type xml but expression is of type character varying Подсказка: You will need to rewrite or cast the expression. </code></pre> <p>Whats wrong?</p> <p><strong>UPDATE 2</strong></p> <p>When i try do this </p> <pre><code> String sql1 = "INSERT INTO xml_docs(cad_number,gkuzu_name,gkuzu,rreq_name,rreq) VALUES(11335464563,"+xml_gkuzu.getName()+",XMLPARSE("+xml_gkuzu.toString()+"),"+xml_rreq.getName()+",XMLPARSE("+xml_rreq.toString()+"))"; </code></pre> <p>i get exeption</p> <pre><code>Exception in thread "main" org.postgresql.util.PSQLException: ERROR: syntax error at or near "bf48e000b0" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload