File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Generate Xml thru database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Generate Xml thru database" Watch "Generate Xml thru database" New topic

Generate Xml thru database

Abhishek Kumar
Ranch Hand

Joined: Dec 19, 2005
Posts: 52
i want to generate a xml file from a table in the database.the database being Oracle 8i and,i am not even able to compile the program.Infact eclipse is stick with the red mark saying the following package doesnot exist.I dont know exactly but i thinl there is some jar problem in my classpath.There may be a few jars in 9i and i may not have it.The packege name is

:--oracle.xml.sql.query.*; we have a class in this package called OracleXMLQuery which does all the work but package pbm.So please suggest what to do???/

Here is my code :---

package com.velozglobal.mcube;

import java.sql.*;
import java.math.*;
import oracle.xml.sql.query.*;
import oracle.jdbc.*;
import oracle.jdbc.driver.*;

public class Xmlquerydb
public static void main(String args[]) throws SQLException
String tabName = "Abhishek";
String user = "scott/tiger";

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

//initiate a JDBC connection
Connection conn =
DriverManager.getConnection("jdbc racle ci8:"+user+"@");

// initialize the OracleXMLQuery
OracleXMLQuery qry = new OracleXMLQuery(conn,"select EMPNO,ENAME from "+tabName );

// structure the generated XML document
qry.setMaxRows(2); // set the maximum number of rows to be returned
qry.setRowsetTag("ROOTDOC"); // set the root document tag
qry.setRowTag("DBROW"); // sets the row separator tag
qry.setStyleSheet("emp.xsl"); // sets the stylesheet

// get the XML document in string format
String xmlString = qry.getXMLString();

// print out the XML document
System.out.println(" OUTPUT IS:\n"+xmlString);

Thanks and Regards,

Abhishek Kumar
Software developer (Apps),
Arbor Networks.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Have you imported the Oracle specific into the project library Path ?

I agree. Here's the link:
subject: Generate Xml thru database
It's not a secret anymore!