Search the web
Sign In
New User? Sign Up
xml-dbms
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
who can tell me how to write my own application using java and xml-d   Message List  
Reply | Forward Message #3849 of 3867 |
Hi, everybody!
who could tell me how to write my own application using java and xml-dbms ?I
want a completely example which can describe the develop steps.i hava a
example ,but it have some errors which i can not correct them.the code is
as follow:

import org.xmlmiddleware.db.*;
import org.xmlmiddleware.utils.XMLMiddlewareException;
import org.xmlmiddleware.xmldbms.*;
import org.xmlmiddleware.xmldbms.tools.*;
import org.xmlmiddleware.xmldbms.actions.ActionCompiler;
import org.xmlmiddleware.xmldbms.actions.*;
import org.xmlmiddleware.xmldbms.datahandlers.*;
import org.xmlmiddleware.xmldbms.filters.*;
import org.xmlmiddleware.xmldbms.keygenerators.*;
import org.xmlmiddleware.xmldbms.maps.*;
import org.xmlmiddleware.xmldbms.maps.factories.*;
import org.xmlmiddleware.xmlutils.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import java.io.*;
import java.util.*;
import javax.sql.*;
public class XMLToDBMSAndViceVersa
{
// Service objects
private DOMToDBMS domToDBMS = null;
private DBMSToDOM dbmsToDOM = null;
private DBMSDelete dbmsDelete = null;
// Credentials for connecting to database
private static String JDBC_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
private static String JDBC_URL = "jdbc:odbc:xmldbms";
private static String JDBC_DBNAME = "test";
private static String JDBC_USER = "sa";
private static String JDBC_PASSWORD = "sa";
// Some file names
private static String mapFilename = "Listing-A.map";
private static String actionFilename = "Listing-C.act";
private static String filterFilename = "Listing-D.act";
// Datahandler class
private static String GENERICHANDLER =
"org.xmlmiddleware.xmldbms.datahandlers.GenericHandler";
// Key generation class
private static String KEYGENERATOR =
"org.xmlmiddleware.xmldbms.keygenerators.KeyGenerator";
// Parser utils class; XML-DBMS does not yet support JAXP, so such operations as
XML parsing and serializing
// needs to be a little customized for each parser. this is the class for
supporting Xerces parser.
private static String PARSERUTILSCLASS =
"org.xmlmiddleware.xmlutils.external.ParserUtilsXerces";
private static boolean VALIDATING_PARSER = false;
public static void main(String [] args) {
// Tell the JVM to run finalizers on exit. This is necessary to ensure
// that database connections are properly closed.
System.runFinalizersOnExit(true);
// Creating parser utilities
ParserUtils utils = (ParserUtils)Class.forName(PARSERUTILSCLASS).newInstance();
// Creating a data source and data handler.
DataSource dataSource = new JDBC1DataSource(JDBC_DRIVER, JDBC_URL);
DataHandler dataHandler =
(DataHandler)Class.forName(GENERICHANDLER).newInstance();
dataHandler.initialize(dataSource, JDBC_USER, JDBC_PASSWORD);
// Compiling and instantiating a Map object
MapCompiler compiler1 = new MapCompiler(utils.getXMLReader(VALIDATING_PARSER));
XMLDBMSMap map = compiler1.compile(new InputSource(new
FileReader(mapFilename)));
// Create an object containing information needed to transfer data
TransferInfo transferInfo = new TransferInfo(map);
transferInfo.addDataHandler(JDBC_DBNAME, dataHandler);
// Compiling and instantiating an Action object
ActionCompiler compiler2 = new
ActionCompiler(utils.getXMLReader(VALIDATING_PARSER));
Actions actions = compiler2.compile(map, new InputSource(new
FileReader(actionFilename)));
// Creating and configuring service object
domToDBMS = new DOMToDBMS();
domToDBMS.setCommitMode(DataHandler.COMMIT_AFTERSTATEMENT);
domToDBMS.stopOnException(true);
domToDBMS.setFilterSetReturned(false);
KeyGenerator keyGen = (KeyGenerator)Class.forName(KEYGENERATOR).newInstance();
domToDBMS.addKeyGenerator("UID", keyGen); // Adding used in Listing-A key
generator named UID
// Getting our XML document into DOM document
Document doc = utils.openDocument(new InputSource(new
StringReader(xmlString)),VALIDATING_PARSER);
// Ooops... and our XML file is already in the database!
domToDBMS.storeDocument(transferInfo, doc, actions);
// Creating FilterSet object for retrieving data
FilterCompiler compiler = new FilterCompiler(utils.getXMLReader(validate));
FilterSetfilterSet = compiler.compile(map, new InputSource(new
FileReader(filterFilename)));
// Creating and configuring another service object
dbmsToDOM = new DBMSToDOM(utils);
dbmsToDOM.setDTDInfo(null, null);
Hashtableparams = new Hashtable();
// And now we are getting a DOM document from database
doc = dbmsToDOM.retrieveDocument(transferInfo, filterSet, params, null);
}
}




---------------------------------
ÑÅ»¢ÓÊÏ䣬ÖÕÉú»ï°é£¡

[Non-text portions of this message have been removed]




Fri Nov 23, 2007 6:34 am

leepf7211
Offline Offline
Send Email Send Email

Forward
Message #3849 of 3867 |
Expand Messages Author Sort by Date

Hi, everybody! who could tell me how to write my own application using java and xml-dbms ?I want a completely example which can describe the develop...
ffffffffffc5fffffff...
leepf7211
Offline Send Email
Nov 23, 2007
6:34 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help