Retrieval of xmltype data into java

Hi
Right now we are facing an issue xmltype retrieval from oracle 10g to java.
I used xmltype column.getClobval() to get the xml content, but unable to do the parse to get the xml data.
So i tried getStringval(), getting the xml content as string format and here in this case also, i didn't get document object.
Here is the code snippet:
String sql = "SELECT node_id,node_desc,parent_node_id,e.report_xml.getStringval() FROM TABLE_STRUCTURE e";
st = con.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
Object value[] = { rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4) };
list.add(value);
DOMParser parser = new DOMParser();
parser.parse(rs.getString(4));
doc = (Document) parser.getDocument();
System.out.println(": DOM = " + doc.getClass().getName());
Please do guide in this scenario.
Thanks in advance.
Sirisha

You selected wrong forum. Please post your question into following forum
XML DB

Similar Messages

  • Insert XMLTYPE data into CLOB column

    Hi,
    I am trying to insert XMLTYPE datatype column value into the CLOB datatype column.
    I get an error -
    ORA - 00932: Inconsistent datatypes: expected CLOB got -
    How do I insert xml type data into clob?
    Thanks!

    Here is my sql code:
    I have a view :
    create or replace view test_view
    (id,
    code,
    desc)
    as select
    id,
    code,
    xmlroot(xmlelement("empname", ename), version '1.0') as desc
    from employee;
    I have a table emp_details_table. The columns in the emp_details_table are
    ID number,
    CODE varchar2,
    EMP_DETAILS CLOB
    I am tring to insert the 'test_view' data into the 'emp_details_table' and I get an error cannot insert xmltype data into clob.
    insert into emp_details_table
    (ID , CODE, EMP_DETAILS)
    select
    (ID, CODE, DESC) from test_view;
    Thanks.

  • Retrieval of xmltype data from oracle 10g to java

    Hi
    Right now we are facing an issue on xmltype retrieval from oracle 10g to java.
    I used xmltype column.getClobval() to get the xml content, but unable to do the parse to get the xml data.
    So i tried getStringval(), getting the xml content as string format and here in this case also, i didn't get document object.
    Here is the code snippet:
    String sql = "SELECT node_id,node_desc,parent_node_id,e.report_xml.getStringval() FROM TABLE_STRUCTURE e";
    st = con.createStatement();
    rs = st.executeQuery(sql);
    while (rs.next()) {
    Object value[] = { rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4) };
    list.add(value);
    DOMParser parser = new DOMParser();
    parser.parse(rs.getString(4));
    doc = (Document) parser.getDocument();
    System.out.println(": DOM = " + doc.getClass().getName());
    Please do guide in this scenario.
    Thanks in advance.
    Sirisha

    Please see below link
    http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10790/xdb11jav.htm

  • How to parse xml data into java component

    hi
    everybody.
    i am new with XML, and i am trying to parse xml data into a java application.
    can anybody guide me how to do it.
    the following is my file.
    //MyLogin.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    class MyLogin extends JFrame implements ActionListener
         JFrame loginframe;
         JLabel labelname;
         JLabel labelpassword;
         JTextField textname;
         JPasswordField textpassword;
         JButton okbutton;
         String name = "";
         FileOutputStream out;
         PrintStream p;
         Date date;
         GregorianCalendar gcal;
         GridBagLayout gl;
         GridBagConstraints gbc;
         public MyLogin()
              loginframe = new JFrame("Login");
              gl = new GridBagLayout();
              gbc = new GridBagConstraints();
              labelname = new JLabel("User");
              labelpassword = new JLabel("Password");
              textname = new JTextField("",9);
              textpassword = new JPasswordField(5);
              okbutton = new JButton("OK");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 5;
              gl.setConstraints(labelname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 5;
              gl.setConstraints(textname,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 10;
              gl.setConstraints(labelpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 10;
              gl.setConstraints(textpassword,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 15;
              gl.setConstraints(okbutton,gbc);
              Container contentpane = getContentPane();
              loginframe.setContentPane(contentpane);
              contentpane.setLayout(gl);
              contentpane.add(labelname);
              contentpane.add(labelpassword);
              contentpane.add(textname);
              contentpane.add(textpassword);
              contentpane.add(okbutton);
              okbutton.addActionListener(this);
              loginframe.setSize(300,300);
              loginframe.setVisible(true);
         public static void main(String a[])
              new MyLogin();
         public void reset()
              textname.setText("");
              textpassword.setText("");
         public void run()
              try
                   String text = textname.getText();
                   String blank="";
                   if(text.equals(blank))
                      System.out.println("First Enter a UserName");
                   else
                        if(text != blank)
                             date = new Date();
                             gcal = new GregorianCalendar();
                             gcal.setTime(date);
                             out = new FileOutputStream("log.txt",true);
                             p = new PrintStream( out );
                             name = textname.getText();
                             String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
                             p.println(entry);
                             System.out.println("Record Saved");
                             reset();
                             p.close();
              catch (IOException e)
                   System.err.println("Error writing to file");
         public void actionPerformed(ActionEvent ae)
              String str = ae.getActionCommand();
              if(str.equals("OK"))
                   run();
                   //loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    hi, thanks for ur reply.
    i visited that url, i was able to know much about xml.
    so now my requirement is DOM.
    but i dont know how to code in my existing file.
    means i want to know what to link all my textfield to xml file.
    can u please help me out. i am confused.
    waiting for ur reply

  • "embed" image data into java code

    I have a mind that is it possible embed image file into java code?
    That mean an image file information already store in java code, thus no need using the image file in run-time. Then can prevent user change other image file instead.
    Do anyone try before, are there technologies required?
    I just want to know is it possible or not....thanks.

    technologies? The solution you are asking for is all about storing your data in static variables such as byte[][] used to build your image instance. I guess you should have a look at the different constructors of BufferedImage.

  • How to convert XMLTYPE data into CLOB without using getclobval()

    Please tell me how to convert data which is stored in the table in XMLTYPE column to a CLOB.
    When i use getClobVal(), i get an error. So please tell me some other option except getClobVal()

    CREATE OR REPLACE PACKAGE BODY CONVERT_XML_TO_HTML AS
         FUNCTION GENERATE_HTML(TABLE_NAME VARCHAR2, FILE_NAME VARCHAR2, STYLESHEET_QUERY VARCHAR2, WHERE_CLAUSE VARCHAR2, ORDERBY_CLAUSE VARCHAR2) RETURN CLOB IS
         lHTMLOutput XMLType;
         lXSL CLOB;
              lXMLData XMLType;
              FILEID UTL_FILE.FILE_TYPE;
              HTML_RESULT CLOB;
              SQL_QUERY VARCHAR2(300);
              WHERE_QUERY VARCHAR2(200);
              fileDirectory VARCHAR2(100);
              slashPosition NUMBER;
              actual_fileName VARCHAR2(100);
              XML_HTML_REF_CUR_PT XML_HTML_REF_CUR;
              BEGIN
                   IF WHERE_CLAUSE IS NOT NULL AND ORDERBY_CLAUSE IS NOT NULL THEN
                   SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME ||' WHERE ' || WHERE_CLAUSE || ' ORDER BY ' || ORDERBY_CLAUSE;
                        ELSE IF WHERE_CLAUSE IS NOT NULL AND ORDERBY_CLAUSE IS NULL THEN
                             SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME || ' WHERE ' || WHERE_CLAUSE;
                             ELSE IF WHERE_CLAUSE IS NULL AND ORDERBY_CLAUSE IS NOT NULL THEN
                                  SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME || ' ORDER BY ' || ORDERBY_CLAUSE;
                                  ELSE IF WHERE_CLAUSE IS NULL AND ORDERBY_CLAUSE IS NULL THEN
                                  SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME;
                   END IF;
                        END IF;
                             END IF;
                                  END IF;
                   OPEN XML_HTML_REF_CUR_PT FOR SQL_QUERY;
              lXMLData := GENERATE_XML(XML_HTML_REF_CUR_PT);
                   --lXSL := GET_STYLESHEET(STYLESHEET_QUERY);
                                  if(lXMLData is not null) then
                                  dbms_output.put_line('lXMLData pass');
                                  else
                                            dbms_output.put_line('lXMLData fail');
                   end if;
                   lHTMLOutput := lXMLData.transform(XMLType(STYLESHEET_QUERY));
                   --INSERT INTO TEMP_CLOB_TAB2 VALUES(CLOB(lHTMLOutput));
                   if(lHTMLOutput is not null) then
                                  dbms_output.put_line('lHTMLOutput pass');
                                  else
                                            dbms_output.put_line('lHTMLOutput fail');
                   end if;
                   HTML_RESULT := lHTMLOutput.getclobVal();
                   if(HTML_RESULT is not null) then
                                  dbms_output.put_line('HTML_RESULT pass'||HTML_RESULT);
                                  else
                                            dbms_output.put_line('HTML_RESULT fail');
                   end if;
                   -- If the filename has been supplied ...
         IF FILE_NAME IS NOT NULL THEN
    -- locate the final '/' or '\' in the pathname ...
         slashPosition := INSTR(FILE_NAME, '/', -1 );
         IF slashPosition = 0 THEN
         slashPosition := INSTR(FILE_NAME,'\', -1 );
         END IF;
    -- separate the filename from the directory name ...
         fileDirectory := SUBSTR(FILE_NAME, 1,slashPosition - 1 );
         actual_fileName := SUBSTR(FILE_NAME, slashPosition + 1 );
                   END IF;
                        DBMS_OUTPUT.PUT_LINE(fileDirectory||' ' ||actual_fileName);
                   FILEID := UTL_FILE.FOPEN(fileDirectory,actual_fileName, 'W');
                   UTL_FILE.PUT_LINE(FILEID, '<title> hi </title>');
              UTL_FILE.PUT_LINE(FILEID, HTML_RESULT);
                   UTL_FILE.FCLOSE (FILEID);
    DBMS_OUTPUT.PUT_LINE('CLOB SIZE'||DBMS_LOB.GETLENGTH(HTML_RESULT));               
                   RETURN HTML_RESULT;
                   --RETURN lHTMLOutput;
              EXCEPTION
                        WHEN OTHERS
                             THEN DBMS_OUTPUT.PUT_LINE('ERROR!!!!!!!!!!!!');
              END GENERATE_HTML;
         FUNCTION GENERATE_XML(XML_HTML_REF_CUR_PT XML_HTML_REF_CUR) RETURN XMLType IS
              qryCtx DBMS_XMLGEN.ctxHandle;
              result CLOB;
              result1 xmltype;
              BEGIN
                   qryCtx := DBMS_XMLGEN.newContext(XML_HTML_REF_CUR_PT);
                   result := DBMS_XMLGEN.getXML(qryCtx);
                   --dbms_output.put_line(result);
                   result1 := xmltype(result);
                   INSERT INTO temp_clob VALUES(result);
                   if(result1 is not null) then
                                  dbms_output.put_line('pass');
                                  else
                                            dbms_output.put_line('fail');
                   end if;
                        return result1;
                        DBMS_XMLGEN.closeContext(qryCtx);
         END GENERATE_XML;     
    END CONVERT_XML_TO_HTML;
    This is the code which i am using to generate the XML and subsequently to generate the HTML output out of that using a XSL stylesheet.
    The error is Numeric or value error..

  • How to populate my input data into java bean through

    Hi,
    I have one doubt in swing how many ways we can populate the input properties(data fron gui screen) into my javabean object(Simple POJO)
    Thanks,
    Tuku

    Hi,
    I have one doubt in swing how many ways we can populate the input properties(data fron gui screen) into my javabean object(Simple POJO)
    Thanks,
    Tuku

  • Passing XMLType Data into oracle stored procedure using JDBC

    Hi Friends,
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.
    Following are the environment details
    JDK Version: 1.6
    Oracle: 10g
    Server: Tomcat 6.x
    Thanks in Advance

    user4898687 wrote:
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.As stated - no.
    A 'file' is a file system entity. There is no way to pass a 'file' anywhere. Not PL/SQL. Not java.
    Now you can pass a file path (a string) in java and to PL/SQL.
    Or you can pass xml data (a string) in java and to PL/SQL. For PL/SQL you could use eithe a varchar2, if the xml is rather small, or a blob/clob.

  • How to convert Oracle Data into Java Date

    Hi there,
    in JDev 3.2 oracle.jbo.domain.Date was derived from oracle.sql.DATE, which has a timestampValue() method to get a java.sql.Timestamp.
    In Jdev 9.0.3 Date is not!! derived from oracle.sql.DATE, so my previous implementation fails.
    So, How can I get a java.util.Date from oracle.jbo.Date?
    ( I think this is a bug !?)

    Hi Dietmar,
    this is documented in the help; see Reference - Business Components Oracle Domains; then choose 'Date'
    using the dateValue() method on the oracle.jdo.domain.Date gives you a java.sql.Date which is a (subclass of) java.util.Date.
    Cheers, Hans

  • Retrieving cookies when logging into java forums through a java application

    Hello --
    I am currently working on a spider application that will have the ability to login to sites of interest and then begin crawling.
    I thought an easy place to start would be to login to java forums. However, I have run into a bit of a snag with all of the cookies....
    The following is the information that I am posting:
    action = "login"
    url = "http://forum.java.sun.com/index.jsp"
    UserId     // my username
    Password // my password
    Submit = "Log in"
    AutoLogin = "1"
    I am doing this using HttpURLConnection that was created using http://developer.java.sun.com/servlet/SessionServlet as the URL. Then I create an output stream etc:
    OutputStream os = huc.getOutputStream();
    os.write(sb.toString().getBytes("US-ASCII")); // where sb is a StringBuffer which contains the above information separated with &'s
    os.close();
    This is when I run into my problem...Next, I try to obtain the session cookies (using the same HttpURLConnection that I posted with) but I am not getting all of the cookies.
    As a test, I set my browser to prompt for cookies and I found that when you submit your login information three cookies are set: JDC, JSessionId, and SessionCredentials. Then two more cookies are set JSessionId again and jiveUserLastVisited -- I think these cookies are actually set while getting the http://forum.java.sun.com/index.jsp page. Anyway the only cookies that I get through my program are JSessionId and jiveUserLastVisited.
    So to remedy this I tried setting followRedirects to false on my HttpURLConnection (before I perform my post) and then I tried to get the Set-Cookie header immediately following my post. What I found was after calling getFieldHeader() my connection has changed -- when I do a getConnection on my HttpURLConnection the connection has changed to the second page (http://forum.java.sun.com/index.jsp) even with redirects set to false.
    I guess my inexperience with web applications has caught up with me. Does anybody have any ideas?
    Thanks,
    Lisa

    Lisa
    Did you get any reply on this ?? I am also writing a similar web crawler and i also ran into similar problems.
    let me know if you found the solution. thanks.
    -P

  • Problem converting XMLTYPE data into database rows.

    Can anyone help with this ?
    I�ve got an XML document like the following:
    <ROWSET><ROW>><NAME>John</NAME></ROW></ROWSET>
    I want to extract the �Name� element and insert it into a table that has one column:
    create table employee
    (empname varchar2(50));
    The following PL/SQL block does the job:
    begin
    insert into employee
    (empname)
    select extractvalue(value(xmltab),'/ROW/NAME')
    from table(xmlsequence(extract(xmltype('
    <ROWSET><ROW>><NAME>Cpty 1</NAME></ROW></ROWSET>')
    ,'/ROWSET/ROW'))) xmltab;
    commit;
    end;
    However, instead of having the XML string embedded in the actual SQL statement I would like to assign the XML string to a variable (of type XMLTYPE) and refer to the variable in the SQL statement i.e.
    declare
    v_xml xmltype;
    begin
    v_xml := xmltype(�<ROWSET><ROW>><NAME>John</NAME></ROW></ROWSET>�)
    insert into employee
    (empname)
    select extractvalue(value(xmltab),'/ROW/NAME')
    from table(xmlsequence(extract(v_xml,'/ROWSET/ROW'))) xmltab;
    commit;
    end;
    When I run this I get the following exception:
    ORA-22905 Cannot access rows from a non-nested table.
    I can�t understand why the first example works but the second example doesn�t. I want to get the second version working because eventually I want to put this code in a stored proc that excepts an xmltype parameter.
    Any help would be much appreciated.

    Hi
    Now I understand why you want to use an insert as select...
    The following PL/SQL code should work...
    declare
    v_xml xmltype;
    begin
    v_xml := xmltype('<ROWSET><ROW><NAME>John</NAME></ROW></ROWSET>');
    insert into employee (empname)
    select extractvalue(value(t),'/NAME')
    from table(cast(xmlsequence(extract(v_xml, '/ROWSET/ROW/NAME'))as xmlsequencetype)) t;
    commit;
    end;
    Chris

  • How to append 2 xmltype data into 1 xmltype data

    example:
    DECLARE
    fullXmlDoc XMLType;
    _id XMLType;
    _se XMLType;
    _idse XMLType;
    BEGIN
    fullXmlDoc := XMLType.CREATEXML('
    <Resource>
    <identifier qualifier="http://www.oracle.bn/oraCell" value="ChuckTestData11"/>
    <title classification="T" ownerProducer="BLACK HOLE USA">Chucks Full Ora full ALG</title>
    <security classification="S" ownerProducer="BLACK HOLE USA"/>
    </Resource>');
    if( fullXmlDoc.existsnode('/Resource/identifier') = 1)
    then
    DBMS_OUTPUT.PUT_LINE('identifier element');
    _id := fullXmlDoc.extract( '/Resource/identifier');
    end if;
    DBMS_OUTPUT.PUT_LINE('security element');
    _se := fullXmlDoc.extract( '/Resource/security');
    idse := se.insertXMLbefore(_se, se, id);
    END;
    ORA-06550:
    PLS-00306: wrong number of types of arguments in call to "INSERTXMLBEFORE'
    ====
    I want to insert _id before _se and the result _idse should be :
    <identifier qualifier="http://www.oracle.bn/oraCell" value="ChuckTestData11"/>
    <security classification="S" ownerProducer="BLACK HOLE USA"/>
    as in xmltype

    INSERTXMLBEFORE(XMLTYPE_instance,XPath_string, value_expr)
    In your case :
    XMLTYPE_instance and XPath_string both look to be se which does not seem to be correct in first look .. please check the value of XPathstring
    Message was edited by:
    Gajanan Palsule

  • Insert a date into java form

    Hi,
    I am using NetBeans IDE, and trying to create a user interphase which involves having the user enter a date. Anyone know how to force the user to enter a date and nothing else. Could I somehow use JFormattedTextField?
    Also another question. Anyone know how to set the position of the window when it opens up so it doesn't always open up in the top left hand corner of the screen? There is a "form position" in the code area of the forms properites but it is uneditable how do you make this editable?
    thanks.
    Paul

    I believe it is setLocation() for a Window object or JFrame or Frame, you can use the ToolKit to find the hight and width of the screen and do a simple calcultion to make it appear in the middle, or capture the location when you close and save it in a configuation file that you read when you open the window again, that way the user sets the location.

  • How to retrieve the xml data into datagrid in vb6.0 using dom method

    <?xml version="1.0" standalone="yes"?>
    <Student_Details>
      <Student>
        <Name>sandeep</Name>
        <Age>12</Age>
        <Mobile>123456789</Mobile>
      </Student>
      <Student>
        <Name>ololjk</Name>
        <Age>kjlokmo</Age>
        <Mobile>njonojniohuj</Mobile>
      </Student>
      <Student>
        <Name>Sandeep Pr</Name>
        <Age>12</Age>
        <Mobile>9865231870</Mobile>
      </Student>
      <Student>
        <Name>ololjk</Name>
        <Age>kjlokmo</Age>
        <Mobile>njonojniohuj</Mobile>
      </Student>
      <Student>
        <Name>ololjk</Name>
        <Age>kjlokmo</Age>
        <Mobile>njonojniohuj</Mobile>
      </Student>
      <Student>
        <Name>ololjk</Name>
        <Age>kjlokmo</Age>
        <Mobile>njonojniohuj</Mobile>
      </Student>

    this forum is for vb.net, for vb6 you could try
    http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
    http://forums.codeguru.com/forumdisplay.php?4-Visual-Basic-6-0-Programming
    PS. vb6 is ancient software you might want to consider a language from this century

  • How to bind XMLType data in JDBC application

    Hi
    I have an XMLType column.I was updating that column data as
    update DOCUMENT set RECORD_DATA =sys.XMLType.createXML('" + recordData +"') where doc_id = 100
    It was working fine as long as the recordData length is less than 4000 chars.
    If it is beyond 4000 chars it is giving ORA-01704 "String literal too long"error.The documentation says we have to bind the data if it is more than 4000 chars.
    Can anybody give how we can bind XMLType data in Java.
    can we use prepareStatement.setClob( ) or setObject() ?
    I tried to pass the String in setClob and setObject,but it didn't worked.how do we create XMLType object in Java appplication and pass .
    please give the info.
    Thanks in advance.

    You really need to use the OCI driver if you are dealing with XMLType via JDBC.

Maybe you are looking for

  • Emacs auctex menus empty when not opening file from command line

    I have got a problem with emacs/auctex. In a running emacs editor, if I am opening a .tex file out of the editor, the menus "LaTeX", "Command" and "Math" are empty. That is, upon clicking on them, there is no dropdown list: Example: http://img8.image

  • How to hide the Charecteristics in Bex

    hello, can some body help me solve this issue, i have about 22 characteristics selected in the row's like name, number Etc.. in the Bex.. Obviously all those Characteristics also show's up in the beginning of the report, in the filter area. do somebo

  • Generating intermediate points between two points

    hi, i want to generate the intermediate points between two specified points,is there any functionality in java that generates the intermediate points similiar to the LINEDDA in VC++/SDK.or else please to suggest a better idea of how to get this done.

  • Open Office Not Functioning Properly After Mavericks 10.9.1 Update Today

    Is anyone else getting this issue? Everyone in the company I manage was using MS Office on their Windows-based computers and we were getting a lot of annoying formatting incompatibilities becasue I was using Pages on my Mac. I actually prefer Open Of

  • Blurry Pictures in Premiere

    Hello, I have created a slide show in Photoshop Elements 10. I clicked on output to send it to Premiere Elements 10 because my pictures were blurry/pixilated when I viewed them in full screen preview, but they were not blurry/pixilated in the screen