• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

exporting retreived data on the selection of a tree node into an other table on button click

Hi,

I am having a tree with three node and each node retreiveing data from a database table, for eg


1001(angnr)
        |
         10(ver number)
               |
               20( UA number)
1002(angnr)
       |
       10(ver number)
               |
                30(UA number)

When the user selects particular node and clicks the button, I would like to retreive related data in an xml format and send that data into an other table. Im able to retreive related data based on the user selection of node, but I am unable to send that data. Its giving me an error
>>>java.io.FileNotFoundException: <?xml version = '1.0'?>“
>>>The system cannot find the indicated path

Could anyone please conttribute to this, all contributions will be appreciatted.

Thanks.

my code:-
-----------------------

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // action code for button
       
DefaultMutableTreeNode nodeSelected = (DefaultMutableTreeNode)jTree1.getSelectionPath().getLastPathComponent();
TreeSelectionObject obj = (TreeSelectionObject) nodeSelected.getUserObject();
String angNumber = null;
if ( obj.getType() == TreeSelectionObject.ANGNR ) {    
         angNumber = obj.getNumber();
        System.out.println(obj);
                                                                                     }
      else if ( obj.getType() == TreeSelectionObject.VERNR ) {  
      System.out.println(obj);
               DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)nodeSelected.getParent();
                  obj = (TreeSelectionObject)parentNode.getUserObject();
                  angNumber = obj.getNumber();
                  System.out.println("parent"+obj);
                     }
                                           
       else if ( obj.getType() == TreeSelectionObject.UANR ) {
        System.out.println(obj);
                   DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)nodeSelected.getParent().getParent();
                  obj = (TreeSelectionObject)parentNode.getUserObject();
                  angNumber = obj.getNumber();  
                  System.out.println("parent"+obj);
                  
       //xml code//
      Connection conn;
              try
              {
                  DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());                      
                conn = DriverManager.getConnection ("");
          OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from regdet WHERE ang_nr1 = '" + angNumber + "'");
                              
                              String sx = qry.getXMLString();
                              String tableName = "employeetestinsert";
                              String fileName = sx;
                                          try {
                                          OracleXMLSave save = new OracleXMLSave(conn, tableName);
                                          InputStream is = new FileInputStream(fileName);
                                                                                  int rowCount = save.insertXML(is);
                                is.close();
                                                  }
                                      catch (IOException e) {
                                             System.out.println(e);
                                                         
                                                           }
                              
                                }
                                
                          catch (SQLException e)
                                {
                                    e.printStackTrace();      
                                      System.out.println(e);
                                }


0
vihar123
Asked:
vihar123
  • 33
  • 27
  • 11
  • +2
3 Solutions
 
girionisCommented:
> >>>java.io.FileNotFoundException: <?xml version = '1.0'?>“
> >>>The system cannot find the indicated path

That's a weird error message and I believe it is related to the xml file itself. Can you piost the first few lines? Also try to change this:

<?xml version = '1.0'?>

to this:

<?xml version = "1.0"?>

and tell us what happens.

0
 
CEHJCommented:
>>I would like to retreive related data in an xml format and send that data into an other table.

How would that work - how do you decide what part(s) of the DOM would be included?
0
 
zzynxSoftware engineerCommented:
You pass the content of your query

         qry.getXMLString();

as a filename

>> InputStream is = new FileInputStream(fileName);
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Giant2Commented:
I suggest you to use even to specify the encoding

<?xml version="1.0" encoding="UTF-8"?>
0
 
vihar123Author Commented:
>>>That's a weird error message and I believe it is related to the xml file itself. Can you piost the first few lines? Also try to change this:

well the program is retreiving it into an xml format, and just this i want to send, i dont want to change anything in it

the entire output when im selecting a node and pressing a button is coming like this

----

parent0015,000<<<<<(node being selected and when button clicked)
java.io.FileNotFoundException: <?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <ANG_NR1>0015,000<\ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten<\PROD_BEZ1>
      <KUNDE_NR1>24<\KUNDE_NR1>
      <FAKTOR1>10<\FAKTOR1>
      <BASISPROJEKT1>1234<\BASISPROJEKT1>
      <VER_NR1>1<\VER_NR1>
      <VER_BESH1>Test Arun<\VER_BESH1>
      <GESC_JAHR1>2004<\GESC_JAHR1>
      <CURR1>EUR<\CURR1>
      <GES_KALK1>Arun<\GES_KALK1>
      <KALK_MEK1>Arun<\KALK_MEK1>
      <KALK_ELE1>Arun<\KALK_ELE1>
      <REF_NR1>0015<\REF_NR1>
   <\ROW>
   <ROW num="2">
      <ANG_NR1>0015,000<\ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten<\PROD_BEZ1>
      <KUNDE_NR1>24<\KUNDE_NR1>
      <FAKTOR1>10<\FAKTOR1>
      <BASISPROJEKT1>1234<\BASISPROJEKT1>
      <VER_NR1>2<\VER_NR1>
      <VER_BESH1>Test Arun<\VER_BESH1>
      <GESC_JAHR1>2004<\GESC_JAHR1>
      <CURR1>EUR<\CURR1>
      <GES_KALK1>Arun<\GES_KALK1>
      <KALK_MEK1>Arun<\KALK_MEK1>
      <KALK_ELE1>Arun<\KALK_ELE1>
      <REF_NR1> <\REF_NR1>
   <\ROW>
<\ROWSET>
 (The system cannot find the indicated path)
0
 
zzynxSoftware engineerCommented:
Did you already try

       int rowCount = save.insertXML(sx);    // omitting the use of InputStream
0
 
zzynxSoftware engineerCommented:
Like I said I think the error is at this line:

>>      InputStream is = new FileInputStream(fileName);

It expects a filename as parameter and you pass it the XML content

Try

       int rowCount = save.insertXML(sx);    // omitting the use of InputStream



0
 
zzynxSoftware engineerCommented:
I mean like this:

                           String sx = qry.getXMLString();
                           String tableName = "employeetestinsert";
                           try {
                                     OracleXMLSave save = new OracleXMLSave(conn, tableName);
                                     int rowCount = save.insertXML(sx);
                           }
0
 
girionisCommented:
zzynx is correct. You need to pass a filename there not the whole xml content. I think this si the same problem you had earlier.
0
 
vihar123Author Commented:
>>>Did you already try

       int rowCount = save.insertXML(sx);    // omitting the use of InputStream

its giving me many errors

oracle.xml.sql.OracleXMLSQLException:  ' java.sql.SQLException:  Ora-01400:  Do not insert from ZERO in ("ANSKA_TEST"."employeetestinsert"."emp_no") possible ' with the processing of ROW element 2.  All earlier XML lines changes were put back.  in XML document found.

at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2286)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1361)
        at gui5.jButton1ActionPerformed(gui5.java:540)
        at gui5.access$200(gui5.java:31)
        at gui5$3.actionPerformed(gui5.java:178)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
0
 
girionisCommented:
If you want to pass the xml string then you will have to create a Document and pass it as the argument insted fo the InputStream.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(sx)));

You will also need to import javax.xml.parsers.*;

0
 
girionisCommented:
0
 
zzynxSoftware engineerCommented:
>> its giving me many errors
That's yet another problem. But at least the original is solved.
0
 
zzynxSoftware engineerCommented:
>> This is the exact same answer I gave you here
I already thought I had seen that before ;°)
0
 
vihar123Author Commented:
>>>>Document document = builder.parse(new InputSource(new StringReader(sx)));

its giving an error as cannot resolve sombol: class Document and class InoutSource
0
 
zzynxSoftware engineerCommented:
javax.swing.text.Document
org.xml.sax.InputSource
0
 
vihar123Author Commented:
>>>>> its giving me many errors
That's yet another problem. But at least the original is solved.

i think the better way is to stick to the inputstream and save the retreived xml (sx) in some temp file and parse it and provide an overwrite funcionality....

or is there some better way, i think experience counts more.....:-)
0
 
vihar123Author Commented:
>>>javax.swing.text.Document
org.xml.sax.InputSource

giving the error as

incompatible types
found   : org.w3c.dom.Document
required: javax.swing.text.Document
                                                
javax.swing.text.Document document = builder.parse(new org.xml.sax.InputSource(new StringReader(sx)));
                                                                                                                  ^
1 error
0
 
girionisCommented:
> javax.swing.text.Document documen

should also be a org.w3c.dom.Document
0
 
zzynxSoftware engineerCommented:
So:

import org.xml.sax.*;
import org.w3c.dom.*;
0
 
vihar123Author Commented:
i tried this and its giving me the same error as before, given below


try {
  OracleXMLSave save = new OracleXMLSave(conn, tableName);
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  DocumentBuilder builder = factory.newDocumentBuilder();
  Document document = builder.parse(new InputSource(new StringReader(sx)));
 int rowCount = save.insertXML(sx);

}
      catch (ParserConfigurationException e) {
           System.out.println(e);
                                                         
                       }
        catch (SAXException e) {
       System.out.println(e);
                                                         
         }
             catch (IOException e) {
       System.out.println(e);
         }
--------------------------------------------------------------

oracle.xml.sql.OracleXMLSQLException:  ' java.sql.SQLException:  Ora-01400:  Do not insert from ZERO in ("ANSKA_TEST"."employeetestinsert"."emp_no") possible ' with the processing of ROW element 2.  All earlier XML lines changes were put back. found in XML document.

 at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2286)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1361)
        at gui5.jButton1ActionPerformed(gui5.java:547)
        at gui5.access$200(gui5.java:35)
        at gui5$3.actionPerformed(gui5.java:182)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
 
0
 
girionisCommented:
Are you sure you are allowed to insert 0 (zero) in the column?
0
 
Giant2Commented:
>Ora-01400:  Do not insert from ZERO in ("ANSKA_TEST"."employeetestinsert"."emp_no") possible ' with the processing of ROW element 2.

if you can see the xml produced search in it ANSKA_TEST or employeetestinsert or emp_no. I believe the error is in the data you try to insert using xml.
0
 
Giant2Commented:
the table is emplyeetestinsert and the column is emp_no. Probably you are inserting a value not agree with what type/value is declared in the OracleDB.
0
 
Giant2Commented:
>...with the processing of ROW element 2.

So search the second row you try to insert in that table (llok at the particular column).
0
 
vihar123Author Commented:
when im saving this as an xml file and giving it as  a file name to the input stream, its inserting without any problem, so i think the problem is not with the table.....
can i save the retreived xml file temporarily and overwrite it all the time button has been clicked???
0
 
zzynxSoftware engineerCommented:
>> can i save the retreived xml file temporarily and overwrite it all the time button has been clicked???
Yes, no problem
0
 
zzynxSoftware engineerCommented:
You can do something like this

File theFile = new File("<your path to a temp file>");
if (theFile.exists())
   theFile.delete()

// Here, the file doesn't exist yet...
if ( theFile.createNewFile() ) { // ...and was successfully created
   theFile.deleteOnExit(); // make sure the temporary file is deleted when the application exits
   // Do your stuff
}
0
 
vihar123Author Commented:
when im trying like this its not accepting the path, its giving error as >>>illegal escape characters

-----------------
String sx = qry.getXMLString();
String tableName = "employeetestinsert";
String fileName = "temp.xml";
try {
OracleXMLSave save = new OracleXMLSave(conn, tableName);
File fileName = new File("I:\Gotla\java");
if (fileName.createNewFile() ) {
theFile.deleteOnExit();
 }
if (fileName.exist())
fileName.delete();

InputStream is = new FileInputStream(fileName);
 int rowCount = save.insertXML(sx);
is.close();
}
0
 
zzynxSoftware engineerCommented:
Make that

   File file = new File("I:/Gotla/java/temp.xml");
0
 
zzynxSoftware engineerCommented:
1) "file" instead of "fileName" since fileName is already used
2) forward slashed instead of backslashes
0
 
zzynxSoftware engineerCommented:
>> String sx = qry.getXMLString();
>> String tableName = "employeetestinsert";
>> String fileName = "temp.xml";
>> try {
>>     OracleXMLSave save = new OracleXMLSave(conn, tableName);
>>     File fileName = new File("I:\Gotla\java");                                          /// <<<<<<< here you reuse the variable "fileName"
>>     if (fileName.createNewFile() ) {
>>        theFile.deleteOnExit();
>>         }
>>     if (fileName.exist())
>>              fileName.delete();

>>      InputStream is = new FileInputStream(fileName);
>>      int rowCount = save.insertXML(sx);                     /// <<<<<<<<<<< Aren't you supposed to use the file here??
>>         is.close();
>>  }
0
 
zzynxSoftware engineerCommented:
String sx = qry.getXMLString();
String tableName = "employeetestinsert";
String fileName = "I:/Gotla/java/temp.xml";
try {
      OracleXMLSave save = new OracleXMLSave(conn, tableName);
      File theFile = new File(fileName);
      if (theFile.exist())                              // <<<<<< First delete it if it exists from another get/send action
        theFile.delete();
      if (theFile.createNewFile() )              // <<<<<<< now create it
         theFile.deleteOnExit();

      InputStream is = new FileInputStream(theFile);
      int rowCount = save.insertXML(theFile);                      // <<<<<<<<<< not sure
      is.close();
}
0
 
vihar123Author Commented:
its giving me an exception as file not found, i think something is wrong in this code, can u please make the needed changes, thanks.


String sx = qry.getXMLString();
String tableName = "employeetestinsert";
String fileName = "temp.xml";
try {
 OracleXMLSave save = new OracleXMLSave(conn, tableName);
 InputStream is = new FileInputStream(fileName);
 File file = new File("I:/Gotla/java/temp.xml");
 if (file.createNewFile() ) {
file.deleteOnExit();
    }
if (file.exists())
file.delete();

int rowCount = save.insertXML(sx);
System.out.println("successfully created");
is.close();
}
0
 
zzynxSoftware engineerCommented:
Of course drive I: won't exist on all systems on which you run this program, therefor maybe you better use

       File.createTempFile()

This way, you're also get rid of the problem of already existing files.


String sx = qry.getXMLString();
String tableName = "employeetestinsert";
try {
      OracleXMLSave save = new OracleXMLSave(conn, tableName);
      File theFile = File.createTempFile("myApp", "xml");
      theFile.deleteOnExit();

      // use theFile
}
0
 
zzynxSoftware engineerCommented:
>> its giving me an exception as file not found

Of course! You have:

String fileName = "temp.xml";
...
InputStream is = new FileInputStream(fileName);     // <<<< here, the file "temp.xml" doesn't exists yet

Use the code of my last post.
0
 
vihar123Author Commented:
its giving me error:-
cannot resolve symbol
symbol  : method insertXML (java.io.File)
location: class oracle.xml.sql.dml.OracleXMLSave
int rowCount = save.insertXML(theFile);
----------------------------------

try {
OracleXMLSave save = new OracleXMLSave(conn, tableName);
File theFile = new File(fileName);
if (theFile.exists())
theFile.delete();
if (theFile.createNewFile() )                                                   theFile.deleteOnExit();

InputStream is = new FileInputStream(theFile);
      int rowCount = save.insertXML(theFile);                                                                is.close();
}
0
 
zzynxSoftware engineerCommented:
If you wrote this:

>> when im saving this as an xml file and giving it as a file name to the input stream, its inserting without any problem
(btw, have you checked that it was really written correct to the database?)

what code did you have?
0
 
zzynxSoftware engineerCommented:
>> its giving me error:-
>> cannot resolve symbol symbol  : method insertXML (java.io.File)

These are the possible usages:

 int insertXML(org.w3c.dom.Document doc)
 int insertXML(java.io.InputStream xmlStream)    // Think you probably need this one
 int insertXML(java.io.Reader xmlStream)
 int insertXML(java.lang.String xmlDoc)
 int insertXML(java.net.URL url)  
0
 
zzynxSoftware engineerCommented:
Don't solve the error by just writing

      InputStream is = new FileInputStream(theFile);
      int rowCount = save.insertXML(is); // <<<<<<<<<<< the file is still empty at this stage

That's why I asked:
>> what code did you have?
0
 
vihar123Author Commented:
>>>what code did you have?

i saved the retreived xml as emps.xml and put it in the I drive and its exactly filling the table......


----

import java.sql.*;
import java.math.*;
import oracle.xml.sql.query.*;
import oracle.jdbc.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.dml.*;
import oracle.xml.sql.*;
import java.net.*;
import oracle.xml.parser.v2.*;
import java.io.*;
import oracle.xml.sql.dml.OracleXMLSave;
import oracle.sql.CLOB.*;


public class testxml2
{
    public static void main(String args[]) throws SQLException
    {
       
        Connection conn;
       
 try
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                     
 conn = DriverManager.getConnection ("");
                       
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from emp1");
("java.class.path") );

String sx = qry.getXMLString();
String tableName = "employeetestinsert";
String fileName = "emps.xml";
                              
                                                           
try {
 OracleXMLSave save = new OracleXMLSave(conn, tableName);
InputStream is = new FileInputStream(fileName);
int rowCount = save.insertXML(is);
is.close();
                                          
System.out.println("Inserted successfully" + "  " + "*"+ rowCount +"*"+ "  " + "rows into" + "  " + tableName);      
                                }
catch (IOException e) {
System.out.println(e);
                                                         
  }
                    
                                }
                             catch (SQLException e)
                                         {
                                          e.printStackTrace();      
                                      
                                          System.out.println(e);
                                          
                                         }
       
    }
}      
0
 
zzynxSoftware engineerCommented:
>> i saved the retreived xml as emps.xml and put it in the I drive and its exactly filling the table......
All right.

      // 1) Create the temporary file as stated above

      // 2) Save the retreived xml in the temporary file created (instead of emps.xml)

      // 3) then use it:
      InputStream is = new FileInputStream(theFile);
      int rowCount = save.insertXML(is);
0
 
zzynxSoftware engineerCommented:
I think now you have all components. Just have to stick them together ;°)
0
 
vihar123Author Commented:
>>>// 1) Create the temporary file as stated above

i saved it manually and stored it
well thats what my question was how to save the retreived file and also overwrite it
0
 
zzynxSoftware engineerCommented:
>> well thats what my question was how to save the retreived file and also overwrite it
And that after 45 comments in this thread! Phew...
0
 
vihar123Author Commented:
>>>can i save the retreived xml file temporarily and overwrite it all the time button has been clicked???

i think i asked much before :-))
0
 
zzynxSoftware engineerCommented:
Well, I suppose you have the xml content in a String object:

import java.io.*;

// 1) Create the temporary file as stated above

// 2)

try {
        BufferedWriter out = new BufferedWriter(new FileWriter(theFile));      // <<<<<< theFile being the File object representing the temporary file
        out.write(yourXMLContent);        //<<<<<< your String
        out.flush();
        out.close();
} catch (IOException e) {
}
0
 
vihar123Author Commented:
>>>its again giving me the same error....its nicely creating the xml file but when inserting giving me this error.


try {
 OracleXMLSave save = new OracleXMLSave(conn, tableName);
                                                
File theFile = new File(fileName);
if (theFile.exists())
theFile.delete();
if (theFile.createNewFile() )                                                   theFile.deleteOnExit();
               try {
              BufferedWriter out = new BufferedWriter(new FileWriter(theFile));                                     out.write(sx);
                out.flush();
              out.close();
                                                                  } catch (IOException e) {
                                                                        }

       InputStream is = new FileInputStream(fileName);
            int rowCount = save.insertXML(is);              
            is.close();
                                                
                                    }
                                      catch (IOException e) {
                                             System.out.println(e);
                                                         
                                                           }
                              
                                   
                                }
                          catch (SQLException e)
                                {
                                    e.printStackTrace();      
                                      System.out.println(e);
                                }
                                                                                                                          
                                                                                                                   
                                                                                                                     }
       
                                                                                                             }
       

------------------------------------


oracle.xml.sql.OracleXMLSQLException:  ' java.sql.SQLException:  Ora-01400:  Do not insert from ZERO in ("ANSKA_TEST"."employeetestinsert"."emp_no") possible ' with the processing of ROW element 2.  All earlier XML lines changes were put back.  in XML document found.


at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2317)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1385)
        at gui5.jButton1ActionPerformed(gui5.java:564)
        at gui5.access$200(gui5.java:35)
        at gui5$3.actionPerformed(gui5.java:182)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
0
 
zzynxSoftware engineerCommented:
Replace
>> InputStream is = new FileInputStream(fileName);
by
     InputStream is = new FileInputStream(theFile);

0
 
zzynxSoftware engineerCommented:
Comment out some code so you just keep the saving of the XML content to a temporary file.
Compare the content of that file with the one you saved manually.
Do you see any differences? (length, content, ...)

If they are equal, it should work like with the manually saved file.
0
 
vihar123Author Commented:
ok i could find out the reason, its not accepting values that are starting with 0, so how can i make my table accept values starting with 0. i want to create a new table and then give it in my prg to populate it
0
 
zzynxSoftware engineerCommented:
>> ok i could find out the reason, its not accepting values that are starting with 0
Then how come that importing the manually saved file worked correctly?
0
 
vihar123Author Commented:
>>>Then how come that importing the manually saved file worked correctly?

there im accessing an other table that has no values starting with 0
0
 
zzynxSoftware engineerCommented:
>> there im accessing an other table that has no values starting with 0
If your goal is to find a problem as quickly as possible, it's no good idea to compare your app's behaviour on different input data...
0
 
vihar123Author Commented:
actually i was accessing a table that didnt had the structure of the retreived xml data, now i have created a new table with the same schema, its running but the strange thing is its not showing any values in the table, its showing as inserted 2 rows, but when im giving the select query, its not showing any values, but there are two rows being created,  and even the temp.xml is not found in the drive, i dont know why its not creating the temp.xml file

...............

String sx = qry.getXMLString();
String tableName = "xins";
                            
String fileName =  "I:/Gotla/java/temp.xml";
                                
 try {
OracleXMLSave save = new OracleXMLSave(conn, tableName);
File theFile = new File(fileName);
if (theFile.exists())
theFile.delete();
if (theFile.createNewFile() )                                                       theFile.deleteOnExit();
               System.out.println("file created successfully");
               try {
              BufferedWriter out = new BufferedWriter(new FileWriter(theFile));    
            out.write(sx);                                                        
              out.flush();
              out.close();
                                                                  } catch (IOException e) {
                                                                        }

       InputStream is = new FileInputStream(theFile);
            int rowCount = save.insertXML(is);              
            is.close();
                                                
                                    }
                                      catch (IOException e) {
                                             System.out.println(e);
                                                         
                                                           }
                              
                                   
                                }
                          catch (SQLException e)
                                {
                                    e.printStackTrace();      
                                      System.out.println(e);
                                }
                                                                                                                          
                                                                                                                   
                                                                                                                     }
       
                                                                                                             }
0
 
vihar123Author Commented:
oops sorry its creating xml file, actually i gave delete file on exit.......#

but the strange thing is that the prg is running, but its not doing its job...i dont understand why its just inserting two rows and not showing the values
0
 
zzynxSoftware engineerCommented:
>> i dont understand why its just inserting two rows and not showing the values
Me neither. Sorry.
0
 
zzynxSoftware engineerCommented:
Did it show the values when you imported the manually create file?
0
 
vihar123Author Commented:
>>>Did it show the values when you imported the manually create file?

yes ofcourse

this is the emps.xml thats runinng successfully

<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <EMP_NAME>Zdena</EMP_NAME>
      <EMP_NO>1015</EMP_NO>
      <EMP_DESIG>Project Manager</EMP_DESIG>
      <EMP_DEPT>EDPT</EMP_DEPT>
      <EMP_SAL>10000</EMP_SAL>
      <EMP_COMM>70</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="2">
      <EMP_NAME>John</EMP_NAME>
      <EMP_NO>1001</EMP_NO>
      <EMP_DESIG>Manager</EMP_DESIG>
      <EMP_DEPT>Finance 1</EMP_DEPT>
      <EMP_SAL>5000</EMP_SAL>
      <EMP_COMM>50</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="3">
      <EMP_NAME>Christian</EMP_NAME>
      <EMP_NO>1002</EMP_NO>
      <EMP_DESIG>Manager</EMP_DESIG>
      <EMP_DEPT>Personal 1</EMP_DEPT>
      <EMP_SAL>7000</EMP_SAL>
      <EMP_COMM>20</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="4">
      <EMP_NAME>Markus</EMP_NAME>
      <EMP_NO>1003</EMP_NO>
      <EMP_DESIG>DBA</EMP_DESIG>
      <EMP_DEPT>Sales 1</EMP_DEPT>
      <EMP_SAL>4000</EMP_SAL>
      <EMP_COMM>34</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="5">
      <EMP_NAME>Kajin</EMP_NAME>
      <EMP_NO>1004</EMP_NO>
      <EMP_DESIG>Distributor</EMP_DESIG>
      <EMP_DEPT>Dist 1</EMP_DEPT>
      <EMP_SAL>5000</EMP_SAL>
      <EMP_COMM>25</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="6">
      <EMP_NAME>Stephen</EMP_NAME>
      <EMP_NO>1005</EMP_NO>
      <EMP_DESIG>HW Manager</EMP_DESIG>
      <EMP_DEPT>Hardware 1</EMP_DEPT>
      <EMP_SAL>8000</EMP_SAL>
      <EMP_COMM>25</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="7">
      <EMP_NAME>Muller</EMP_NAME>
      <EMP_NO>1006</EMP_NO>
      <EMP_DESIG>HW Specilaist</EMP_DESIG>
      <EMP_DEPT>Hardware 2</EMP_DEPT>
      <EMP_SAL>2500</EMP_SAL>
      <EMP_COMM>25</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="8">
      <EMP_NAME>Arun</EMP_NAME>
      <EMP_NO>1007</EMP_NO>
      <EMP_DESIG>Programmer</EMP_DESIG>
      <EMP_DEPT>Software 1</EMP_DEPT>
      <EMP_SAL>4000</EMP_SAL>
      <EMP_COMM>24</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="9">
      <EMP_NAME>Meng</EMP_NAME>
      <EMP_NO>1017</EMP_NO>
      <EMP_DESIG>Trainee</EMP_DESIG>
      <EMP_DEPT>Const</EMP_DEPT>
      <EMP_SAL>4000</EMP_SAL>
      <EMP_COMM>50</EMP_COMM>
      <EMP_LOC>fe</EMP_LOC>
   </ROW>
   <ROW num="10">
      <EMP_NAME>Jia uei</EMP_NAME>
      <EMP_NO>1011</EMP_NO>
      <EMP_DESIG>Trainee#</EMP_DESIG>
      <EMP_DEPT>Construction</EMP_DEPT>
      <EMP_SAL>4000</EMP_SAL>
      <EMP_COMM>50</EMP_COMM>
      <EMP_LOC>se</EMP_LOC>
   </ROW>
   <ROW num="11">
      <EMP_NAME>Effah</EMP_NAME>
      <EMP_NO>1012</EMP_NO>
      <EMP_DESIG>Researcher</EMP_DESIG>
      <EMP_DEPT>Research</EMP_DEPT>
      <EMP_SAL>5000</EMP_SAL>
      <EMP_COMM>20</EMP_COMM>
      <EMP_LOC>AF</EMP_LOC>
   </ROW>
   <ROW num="12">
      <EMP_NAME>Johannes</EMP_NAME>
      <EMP_NO>1014</EMP_NO>
      <EMP_DESIG>Technician</EMP_DESIG>
      <EMP_DEPT>TE</EMP_DEPT>
      <EMP_SAL>4500</EMP_SAL>
      <EMP_LOC>LA</EMP_LOC>
   </ROW>
</ROWSET>

-------
this is the temp.xml, which is not showing any values

<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <ANG_NR1>0015,000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>10</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>1</VER_NR1>
      <VER_BESH1>Test Arun</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Arun</GES_KALK1>
      <KALK_MEK1>Arun</KALK_MEK1>
      <KALK_ELE1>Arun</KALK_ELE1>
      <REF_NR1>0015</REF_NR1>
   </ROW>
   <ROW num="2">
      <ANG_NR1>0015,000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>10</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>2</VER_NR1>
      <VER_BESH1>Test Arun</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Arun</GES_KALK1>
      <KALK_MEK1>Arun</KALK_MEK1>
      <KALK_ELE1>Arun</KALK_ELE1>
      <REF_NR1> </REF_NR1>
   </ROW>
</ROWSET>

0
 
vihar123Author Commented:
the schema of the table looks like this............


CREATE TABLE xins (
  angnr1test        VARCHAR2(2040) NULL,
  projnr1test       VARCHAR2(2040) NULL,
  prodbez1test      VARCHAR2(2040) NULL,
  kundenr1test      VARCHAR2(2040) NULL,
  faktor1test       VARCHAR2(2040) NULL,
  basisprojekt1test VARCHAR2(2040) NULL,
  vernr1test        VARCHAR2(2040) NULL,
  verbesh1test      VARCHAR2(2040) NULL,
  gescjahr1test     VARCHAR2(2040) NULL,
  curr1test         VARCHAR2(2040) NULL,
  geskalk1test      VARCHAR2(2040) NULL,
  kalkmek1test      VARCHAR2(2040) NULL,
  kalkele1test      VARCHAR2(2040) NULL,
  refnr1test        VARCHAR2(2040) NULL
)
  PCTUSED    0
/
0
 
zzynxSoftware engineerCommented:
That certainly looks rather different from:

<ROWSET>
   <ROW num="1">
      <ANG_NR1>0015,000<\ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten<\PROD_BEZ1>
      <KUNDE_NR1>24<\KUNDE_NR1>
      <FAKTOR1>10<\FAKTOR1>
      <BASISPROJEKT1>1234<\BASISPROJEKT1>
      <VER_NR1>1<\VER_NR1>
      <VER_BESH1>Test Arun<\VER_BESH1>
      <GESC_JAHR1>2004<\GESC_JAHR1>
      <CURR1>EUR<\CURR1>
      <GES_KALK1>Arun<\GES_KALK1>
      <KALK_MEK1>Arun<\KALK_MEK1>
      <KALK_ELE1>Arun<\KALK_ELE1>
      <REF_NR1>0015<\REF_NR1>
   <\ROW>
0
 
zzynxSoftware engineerCommented:
And you think the problem is with

         <ANG_NR1>0015,000<\ANG_NR1>          // <<<<< this starting with '0'? I don't think that should be a problem.
0
 
vihar123Author Commented:
>>>That certainly looks rather different from:

ya but i think it doesnt make any diff, the entire structure is same i think....and when given varchar1(2040), it shld take in the values
0
 
vihar123Author Commented:
>>>And you think the problem is with

         <ANG_NR1>0015,000<\ANG_NR1>          // <<<<< this starting with '0'? I don't think that should be a problem.

me neither, if it is, the prg shld give run time error, but its running smoothly, but when iam coming to my db and checking the table, there are just two blank rows........
i dont know if its the prg fault or the table fault or something else
0
 
girionisCommented:
>  <ANG_NR1>0015,000<\ANG_NR1>

Shouldn't this be:

<ANG_NR1>0015,000</ANG_NR1>
0
 
girionisCommented:
... or in fact your whole xml file. You are using the opposite slash, \ instead of /.
0
 
Giant2Commented:
What is the full excetion it gaves now?
0
 
vihar123Author Commented:
>>>or in fact your whole xml file. You are using the opposite slash, \ instead of /.

this is the xml file that is being retreived, its not giving any exception, just not showing any values........


<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <ANG_NR1>0015.000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>1</VER_NR1>
      <VER_BESH1>test eraslan test-db Praktikanten</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Schlegel</GES_KALK1>
      <KALK_MEK1>Schlegel</KALK_MEK1>
      <KALK_ELE1>Schlegel</KALK_ELE1>
      <REF_NR1>1219.001</REF_NR1>
   </ROW>
   <ROW num="2">
      <ANG_NR1>0015.000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>2</VER_NR1>
      <VER_BESH1>Test Arun</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <KALK_MEK1>Arun</KALK_MEK1>
   </ROW>
</ROWSET>
0
 
girionisCommented:
Do you get any exceptions/errors? If yes then post them please.
0
 
vihar123Author Commented:
>>>Do you get any exceptions/errors? If yes then post them please.

its quite strange, when im having three nodes for eg:-
1001(angnr)
        |
         10(ver number)
               |
               20( UA number)
on selecting first node, its giving me an exception "java.sql.SQLException: ORA-01722: invalid numberl", one selecting second one its not giving any and on selecting the third one its again giving me the same.

and after selecting one node and clicking action button, its creating and deleting temp.xml but not displaying any values in the db table. its just inserting two blank rows.

when im trying with an other node, its giving the above invalid number exception and also creating temp.xml but its giving me all the below errors and also its not deleting the temp.xml at the close of the file.


oracle.xml.sql.OracleXMLSQLException: 6-byte UTF8 encoding not supported.
        at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2322)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1385)
        at gui5.jButton1ActionPerformed(gui5.java:564)
        at gui5.access$200(gui5.java:35)
        at gui5$3.actionPerformed(gui5.java:182)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


-------------------
code
------------
 Connection conn1;      
       Statement stmt1;      
       ResultSet rset1 = null;  
     
       
        try
        {
            DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                     
           
            conn1 =
            DriverManager.getConnection ("");
           
            stmt1 = conn1.createStatement ();
                rset1 = stmt1.executeQuery("select * from regdet");
                
                           while (rset1.next())
               {
                       
                DefaultMutableTreeNode Angnr = new DefaultMutableTreeNode( new TreeSelectionObject(TreeSelectionObject.ANGNR, rset1.getString("ang_nr1")) );
              topnode.add(Angnr);              
              DefaultMutableTreeNode Version = new DefaultMutableTreeNode( new TreeSelectionObject(TreeSelectionObject.VERNR, rset1.getString("ver_nr1")) );
              Angnr.add(Version);
              DefaultMutableTreeNode UA = new DefaultMutableTreeNode( new TreeSelectionObject(TreeSelectionObject.UANR, rset1.getString("faktor1")) );
              Version.add(UA);
           
              }
                              conn1.close();
                              stmt1.close();                                                      
                              rset1.close();
                              
                    jTree1.setRootVisible(true);
                    treeModel.reload();      
                   
                     
        }
                 
        catch (SQLException e)
        {
            System.out.println(e);
        }
       
                         /**** Tree Action *****/
          jTree1.addTreeSelectionListener(new TreeSelectionListener() {
              
                public void valueChanged(TreeSelectionEvent evt) {
                                                                                       
                                 TreePath tp = evt.getNewLeadSelectionPath();
                             Connection conn2;
                               Statement stmt2;
                               ResultSet rset2 = null;
                               DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) tp.getLastPathComponent();                               
                               String empNo = node1.toString();
             
                                                              
                               try
                                {
                              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                     
                        conn2 = DriverManager.getConnection ("");
           
                              stmt2 = conn2.createStatement ();
                rset2 = stmt2.executeQuery("select * from regdet WHERE ang_nr1 = '" + empNo + "'");


                                  
                               
                               while (rset2.next())
                           {
                            jTextField1.setText(node1.toString());
                            jTextField2.setText(rset2.getString("ang_nr1"));
                            jTextField3.setText(rset2.getString("prod_bez1"));
                            jTextField4.setText(rset2.getString("kunde_nr1"));
                            jTextField5.setText(rset2.getString("ref_nr1"));
                            jTextField6.setText(rset2.getString("proj_nr1"));
                            jTextField7.setText(rset2.getString("basisprojekt1"));
                            
                           }
                              
                                          conn2.close();
                                          stmt2.close();
                                          rset2.close();
                                     
                                  }                
                 
                 
                          catch (SQLException e)
                                {
                                    System.out.println(e);
                                }
                                                             
                             Connection conn3;
                               Statement stmt3;
                               ResultSet rset3 = null;    
                               DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) tp.getLastPathComponent();                                            
                               String verNo = node2.toString();                               
                               
                   try
                                {
                              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                     
                        conn3 = DriverManager.getConnection ("");
           
                              stmt3 = conn3.createStatement ();
                   rset3 = stmt3.executeQuery("select * from regdet WHERE ver_nr1 = '" + verNo + "'");
                                        
                               clearForm();      
                                              
                               while (rset3.next())
                           {
                            jTextField8.setText(rset3.getString("ver_nr1"));
                                    jTextField9.setText(rset3.getString("gesc_jahr1"));
                                    jTextField10.setText(rset3.getString("ver_besh1"));
                                    jTextField11.setText(rset3.getString("curr1"));
                                    jTextField12.setText(rset3.getString("ges_kalk1"));
                                    jTextField13.setText(rset3.getString("kalk_ele1"));
                                    jTextField14.setText(rset3.getString("kalk_mek1"));
                               }
                              
                                          conn3.close();
                                          stmt3.close();
                                          rset3.close();      
                                    
                                  }
                          
                          catch (SQLException e)
                                {
                                    System.out.println(e);
                                }
                                           
                                  //getting the selected node and giving action to it
                                  
                                  
                                  
                                         
                                        }
                              
                                                  
                                                                                                    }
       
                                                          );      
            
    }  
                                  /* Method for clearing the text fields when new project number is selected */
                            private void clearForm()
                                                {
   
                                              jTextField8.setText("");
                                                jTextField9.setText("");
                                                jTextField10.setText("");
                                                jTextField11.setText("");
                                                jTextField12.setText("");
                                                jTextField13.setText("");
                                                jTextField14.setText("");

                                                }
                              
                              
                              
   
    private void jLabel15ComponentMoved(java.awt.event.ComponentEvent evt) {
       
                                                                                                             }
   
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // action code for button
       
        DefaultMutableTreeNode nodeSelected = (DefaultMutableTreeNode)jTree1.getSelectionPath().getLastPathComponent();
                      TreeSelectionObject obj = (TreeSelectionObject) nodeSelected.getUserObject();
                                        String angNumber = null;
                                  
                                           
                               if ( obj.getType() == TreeSelectionObject.ANGNR ) {    
                                       angNumber = obj.getNumber();
                                       System.out.println(obj);
                                                                                                            
                                                                                                 }
                        else if ( obj.getType() == TreeSelectionObject.VERNR ) {  
                                                                              System.out.println(obj);
                     DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)nodeSelected.getParent();
                                          obj = (TreeSelectionObject)parentNode.getUserObject();
                                          angNumber = obj.getNumber();
                                          System.out.println("parent"+obj);
                                           
else if ( obj.getType() == TreeSelectionObject.UANR ) {
                                               System.out.println(obj);
            DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)nodeSelected.getParent().getParent();
                                           obj = (TreeSelectionObject)parentNode.getUserObject();
                                    angNumber = obj.getNumber();  
                                     System.out.println("parent"+obj);
                                          
                                      
                               
                            //xml code//
                             Connection conn;
                                try
                                {
                              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());                      
                        conn = DriverManager.getConnection ("");
         OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from regdet WHERE ang_nr1 = '" + angNumber + "'");
                              
                              String sx = qry.getXMLString();
                              String tableName = "xins";
                            
                              String fileName =  "I:/Gotla/java/temp.xml";
                                
                                    try {
                                           OracleXMLSave save = new OracleXMLSave(conn, tableName);
                                            //File theFile = File.createTempFile("myApp", "xml");
                                            //theFile.deleteOnExit();
                                                
                                                
                                                File theFile = new File(fileName);
                                                if (theFile.exists())                                                                               theFile.delete();
                                                if (theFile.createNewFile() )              
                                                   theFile.deleteOnExit();
                  System.out.println("file created successfully");
                                 try {
                                BufferedWriter out = new BufferedWriter(new FileWriter(theFile));                                                              out.write(sx);                                                        
                                                        out.flush();
                                                        out.close();
                                                                  } catch (IOException e) {
                                                                        }

                         InputStream is = new FileInputStream(fileName);
                                          int rowCount = save.insertXML(is);              
                                          is.close();
                                          
System.out.println("Inserted successfully" + "  " + "*"+ rowCount +"*"+ "  " + "rows into" + "  " + tableName);      
                               
                                    }
                                      catch (IOException e) {
                                             System.out.println(e);
                                                         
                                                           }
                              
                                   
                                }
                          catch (SQLException e)
                                {
                                    e.printStackTrace();      
                                      System.out.println(e);
                                }
                                                                                                              
                                                                                                                     }
       
                                                                                                             }
0
 
girionisCommented:
For the oracle error message have a look here: http://www.orafaq.com/error/ora-01722.htm

For the OracleXMLSQLException it seems that you are saving the content in an encoding that is not understood. Try changing the encoding of the xml file.
0
 
vihar123Author Commented:
>>>>For the OracleXMLSQLException it seems that you are saving the content in an encoding that is not understood. Try changing the encoding of the xml file.

can u please tell me how to do it, actually i dont want to change anything manually in the xml file, i want to use it only to carry my data, so i dont understand why for each node its acting differently????
0
 
girionisCommented:
> so i dont understand why for each node its acting differently????

Maybe each node has different encoding (non-ascii characters)?
0
 
vihar123Author Commented:
leaving the display of data, why is it deletíng the 2 xml file and why is it not deleting the 1 xml, and why is it giving all these errors when im trying to send 1 xml

not solving but i want to understand why??


1 xml
-------
<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <ANG_NR1>1425.001</ANG_NR1>
      <PROD_BEZ1>NüW Montagelinie manuell D26</PROD_BEZ1>
      <KUNDE_NR1>16</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <VER_NR1>1</VER_NR1>
      <VER_BESH1>Angebotskalk.</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Rummel</GES_KALK1>
      <KALK_MEK1>Hirsch</KALK_MEK1>
      <KALK_ELE1>Rummel</KALK_ELE1>
   </ROW>
   <ROW num="2">
      <ANG_NR1>1425.001</ANG_NR1>
      <PROD_BEZ1>NüW Montagelinie manuell D26</PROD_BEZ1>
      <KUNDE_NR1>16</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <VER_NR1>2</VER_NR1>
      <VER_BESH1>ungültig</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Rummel</GES_KALK1>
      <KALK_MEK1>Hirsch</KALK_MEK1>
      <KALK_ELE1>Rummel</KALK_ELE1>
      <REF_NR1>1425.001    </REF_NR1>
   </ROW>
</ROWSET>


----

2 xml
------

<?xml version = '1.0'?>
<ROWSET>
   <ROW num="1">
      <ANG_NR1>0015.000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>1</VER_NR1>
      <VER_BESH1>test eraslan test-db Praktikanten</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <GES_KALK1>Schlegel</GES_KALK1>
      <KALK_MEK1>Schlegel</KALK_MEK1>
      <KALK_ELE1>Schlegel</KALK_ELE1>
      <REF_NR1>1219.001</REF_NR1>
   </ROW>
   <ROW num="2">
      <ANG_NR1>0015.000</ANG_NR1>
      <PROD_BEZ1>Test-Eraslan Test-DB-Praktikanten</PROD_BEZ1>
      <KUNDE_NR1>24</KUNDE_NR1>
      <FAKTOR1>1.08</FAKTOR1>
      <BASISPROJEKT1>1234</BASISPROJEKT1>
      <VER_NR1>2</VER_NR1>
      <VER_BESH1>Test Arun</VER_BESH1>
      <GESC_JAHR1>2004</GESC_JAHR1>
      <CURR1>EUR</CURR1>
      <KALK_MEK1>Arun</KALK_MEK1>
   </ROW>
</ROWSET>
0
 
zzynxSoftware engineerCommented:
>> its giving me all the below errors and also its not deleting the temp.xml at the close of the file.
When it gives you errors don't expect the temp file to be deleted.
It's only deleted on a "normal" program exit, not when an exception is thrown.
0
 
Giant2Commented:
>oracle.xml.sql.OracleXMLSQLException: 6-byte UTF8 encoding not supported

So like suggest before specify an encoding (supported by OracleXML)
I believe you use a non correct charset.
https://cwisdb.cc.kuleuven.ac.be/ora10doc/server.101/b10749/glossary.htm
0
 
Giant2Commented:
encoding="iso-8859-1" for example goes well?
0
 
Giant2Commented:
I see this:
XML-20063: 6-byte UTF8 encoding not supported
Cause: The XML Parser does not support 6-byte UTF8 encoding scheme. It is also possible that invalid UTF8 characters were misinterpreted as 6-byte UTF8 encoding.
Action: If the data contains invalid UTF8 bytes, fix the input, otherwise if 6-byte UTF8 supported is required, please contact Oracle Support.
0
 
Giant2Commented:
Sorry for not help you.
Bye, Giant.
0
 
zzynxSoftware engineerCommented:
Thanks
I wish we could have helped you better than this.
Did you solved it at last?
0
 
CEHJCommented:
8-)
0
 
vihar123Author Commented:
>>>Did you solved it at last?

not really, but im doing some other imp stuff now.....so will get back with this later, anyway thanks for everything. :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 33
  • 27
  • 11
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now