java: oracle.xml.sql.query oracle.jdbc.driver - Java - Programmation
Marsh Posté le 22-03-2006 à 16:41:10
Tu as essayé en JDBC classique sans XMLQuery ?
Marsh Posté le 23-03-2006 à 09:30:28
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.....
Marsh Posté le 23-03-2006 à 10:52:36
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
Marsh Posté le 22-03-2006 à 16:28:46
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.