Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2449 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  java: oracle.xml.sql.query oracle.jdbc.driver

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

java: oracle.xml.sql.query oracle.jdbc.driver

n°1330327
pato666
Posté le 22-03-2006 à 16:28:46  profilanswer
 

Hello à vous tous.
 
Voila, je rencontre un énorme problème. Non spécialiste en java j'ai quand même écrit une classe qui me permet d'interroger une base oracle  
et de transcrire le resultset en xml.
 
Morceau de code :
 
public class clients_Public_essai
{
     public static void main(String args[]) throws Exception
     {
       
      Class.forName("oracle.jdbc.driver.OracleDriver" );
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn =  
          DriverManager.getConnection("jdbc:oracle:identifiant" );
          OracleXMLQuery qry = new OracleXMLQuery(conn, "select ct.cli_compte REFERENCE, ct.cli_codpost_soc CP, ct.cli_insee_soc INSEE, "
 + " ct.cli_adr1_soc || ' ' || ct.cli_adr2_soc || ' ' || ct.cli_adr3_soc ADRESSE, ct.cli_tel TEL, ct.cli_fax FAX, ct.cli_e_mail EMAIL_CONTACT, '0' ABONNEMENT "
 + " from client ct "
 + " where ct.cli_compte = '2730'" );
           
          qry.setRowsetTag("liste_pro" ); // set the root document tag
          qry.setRowTag("pro" );  
           
          try{      
   
            File output= new File("C:\\output.txt" );
            FileWriter writer = new FileWriter(output);    
            writer.write(qry.getXMLString());
            writer.close();conn.close();
            }
       
           catch (OracleXMLSQLException e)
           {
     
     File output= new File("C:\\output.txt" );
     Exception parent = e.getParentException();
        FileWriter writer = new FileWriter(output);    
        writer.write("PROUT:" + e.getErrorCode() +e.getXMLSQLErrorString() + parent.toString());
     
    }
           
           
     }
}  
 

 
 
Tout se passe comme prévu sauf que output.txt  
 
<?xml version = '1.0'?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: Connexion interrompue</ERROR>

 
Mes imports sont faits, et eclipse ne me lève aucune erreur !
La requête a été verifié.
La connection aussi (je crois que c'est bon)
 
Si quelqu'un peut me sortir cette grosse épine du pied , je lui en serai très reconnaissant.

mood
Publicité
Posté le 22-03-2006 à 16:28:46  profilanswer
 

n°1330342
Smanux
Posté le 22-03-2006 à 16:41:10  profilanswer
 

Tu as essayé en JDBC classique sans XMLQuery ?


---------------
Commons Configuration - http://jakarta.apache.org/commons/configuration
n°1330755
pato666
Posté le 23-03-2006 à 08:32:32  profilanswer
 

Je vais essayer de ce pas

n°1330768
pato666
Posté le 23-03-2006 à 09:30:28  profilanswer
 

Donc :
Il semble que l'erreur ORA-17008 soit levé par java.  
Après recherche sur internet j'obtiens:
 
ORA-17008
 
Symptoms
Attempting to Select from a field (defined as a schema based XMLType) results  
in the following error when using the Thin Driver.
 
java.sql.SQLException: Only LOB or thin Storage is supported in Thin XMLType
 
Executing the Select against a field (defined as a XMLType without a schema reference) works fine.  
 
Cause
The reason for the JDBC Thin Driver failing against the table with an associated schema is because schema based tables required the OCI Driver.
 
The failure is not with the JDBC drivers as they can transport the XMLType bits exactly like they are supposed to. The problem is with the implementation of XMLType. This class is implemented almost entirely as C native methods and requires access to the OCI C library and an OCI connection handle. As a result the XMLType class will not work when using the JDBC Thin driver.
 
Fix
Download and test using the latest JDBC OCI Driver.  
 
Je continue.....

n°1330848
pato666
Posté le 23-03-2006 à 10:52:36  profilanswer
 

Apres modif :
 
import java.sql.*;
import java.io.*;
import oracle.xml.sql.query.*;
import oracle.xml.sql.OracleXMLSQLException;
import oracle.jdbc.driver.*;
 
 public class clients_Public_essai
{
     public static void main(String args[]) throws Exception
     {
      Class.forName("oracle.jdbc.driver.OracleDriver" );
          Connection conn =  
          DriverManager.getConnection("jdbc:oracle:oci8:@DOM","user","Pass" );
             
         
           
          File output= new File("C:\\output.txt" );
        FileWriter writer = new FileWriter(output);
;
           
           
           
          OracleXMLQuery qry = new OracleXMLQuery(conn, "select ct.cli_compte REFERENCE, ct.cli_codpost_soc CP, ct.cli_insee_soc INSEE, "
           + " ct.cli_adr1_soc || ' ' || ct.cli_adr2_soc || ' ' || ct.cli_adr3_soc ADRESSE, ct.cli_tel TEL, ct.cli_fax FAX, ct.cli_e_mail EMAIL_CONTACT, '0' ABONNEMENT "
           + " from client ct, charge_de ce, societe sct "
           + " where ct.cli_id = ce.cli_id and ce.soc_id = sct.soc_id and sct.soc_lbl = 'BAIL'" );
           
          qry.setRowsetTag("liste_pro" ); // set the root document tag
          qry.setRowTag("pro" );  
           
          try{      
   
               
            writer.write(qry.getXMLString());
            writer.close();conn.close();
            }
       
           catch (OracleXMLSQLException e)
           {
     
     
     Exception parent = e.getParentException();  
        writer.write( e.getErrorCode() +e.getXMLSQLErrorString() + parent.toString());
     
    }
           
           
     }
}  
 
 
Ce code passe très bien sur une autre machine que la mienne ??????
 
Or la mienne se connecte en sql+ à oracle sans problème!!
 
Et là, je sais pas quoi dire  


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  java: oracle.xml.sql.query oracle.jdbc.driver

 

Sujets relatifs
Java, Excel et tableaux croisés dynamiques[Java]Arbre n-aire
cryptage des mots de passe pour oracle[Oracle 9i]Export résultat de requête SQL vers fichier XML?
java - serialisationconnexion à une base de données oracle en vb excel
[FOP] Instanciation d'un objet Driver foireuseJava SE 6 bêta, des risques ?
[Java] evenement claviers[Java] comment enregistrer GLcanvas en Jpeg??
Plus de sujets relatifs à : java: oracle.xml.sql.query oracle.jdbc.driver


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR