Here is some code that I am using , it used Oracle's XSQL to create a XML
document from data extracted from the oracle
database. You will have to download the oracle.xml package from the oracle site.
hope that's useful
Santosh
import java.io.*;
import java.sql.*;
import java.math.*;
import oracle.xml.sql.query.*;
public class query2xml
{
public static void main(String args[]) throws SQLException
{
String tabName = "employee";
String xmlfile;
try
{
String productname;
DataInputStream dis;
FileOutputStream fos;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:benmgmt";//replace benmgmt with your odbc dsn
Connection conn = DriverManager.getConnection(url,"userid","password"); //
replace usrid & pwd with actual values
// initialize the OracleXMLQuery
OracleXMLQuery qry = new OracleXMLQuery(conn,"select * from "+tabName
);
// structure the generated XML document
qry.setMaxRows(5); // set the maximum number of rows to be returned
qry.setRowsetTag("RECORDSET"); // set the root document tag
qry.setRowTag("RECORD"); // sets the row separator tag
qry.setStyleSheet("whatever.xsl"); // sets the stylesheet
// get the XML document in string format
String xmlString = qry.getXMLString();
System.out.println("Enter name of XML to be generated");
dis = new DataInputStream(System.in);
xmlfile = dis.readLine();
fos = new FileOutputStream(xmlfile);
byte[] sqlresult = new byte[xmlString.length()];
xmlString.getBytes(0,sqlresult.length,sqlresult,0);
fos.write(sqlresult);
//}
fos.close();
dis.close();
System.out.println(" OUTPUT IS:\n"+xmlString);
}
catch(Exception CE)
{
System.out.println(CE.getMessage());
}
}
}
sun_king <[EMAIL PROTECTED]> on 09/12/2000 01:22:58 PM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Santosh Daryani/IT/Aon Consulting)
Subject: XML, XSL and DB
greetings,
any examples, tutorials about populating a XML file with a DB, then
reading it through an XSL and JSP?
thanks
ejf
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets