Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:15:38+00:00 2026-06-10T00:15:38+00:00

I have a table in Postgresql DROP TABLE xml_docs; CREATE TABLE xml_docs( id serial

  • 0

I have a table in Postgresql

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
)

I use JDBC for data base connection. And i want to insert whole xml document in table.
How can i make this?

UPDATE

Okey. i try

  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();

and get exeption

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.

Whats wrong?

UPDATE 2

When i try do this

 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()+"))";

i get exeption

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: syntax error at or near "bf48e000b0"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:15:39+00:00Added an answer on June 10, 2026 at 12:15 am

    I’m not sure, but try this:

    First convert your XML to a Java String.
    Then create an insert statement und use the XMLPARSE method of PostgreSQL to convert your value to the xml type of PostgreSQL:

    INSERT INTO xml_docs(id, gkuzu) VALUES (1, XMLPARSE('<foo><bar>Hello</bar></foo>'));
    

    See: http://wiki.postgresql.org/wiki/XML_Support

    UPDATE:

    Java code example:

    String sql = "INSERT INTO xml_docs(id, gkuzu) VALUES (?, XMLPARSE(?))";
    [...]
    stmt.setString(2, "<foo>Hello World!</foo>");
    

    This should create this statement:

    INSERT INTO xml_docs(id, gkuzu) VALUES (1, XMLPARSE('<foo>Hello World!</foo>'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my postgresql 8.4 database like this: id(serial), event_type_id(id, foreign
I have the following table and sequence in my postgresql-8.4 database: CREATE TABLE complexobjectpy
I have table Candidates with id (primary key) and application_counter and table Applications with
I have a table word in PostgreSQL DB: CREATE TABLE word ( word_id bigserial
I have the following table in PostgreSQL 8.4.5: snake=> create table gps ( id
I have one postgresql table where I store some stories from different sites. At
I have a table in a postgresql-9.1.x database which is defined as follows: #
I have created a table in postgreSQL. I want to look at the SQL
Related to - PostgreSQL DISTINCT ON with different ORDER BY I have table purchases
I have the following table in my postgreSQL 8.3.14 database timestamp status 2012-03-12 19:15:01

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.