Hi Mark:
   thanks.
   Creating only one copy of collection can avoid the problem.
but the developers of xindice API may need have a look into it to
see if this is a bug or not.

-- 
Jinsuo Zhang

CISE department
Univ of Florida

On Mon, 25 Mar 2002, Mark J. Stang wrote:

> I don't see any obvious errors, but I would create a "singleton"
> collection
> manager.   Do the database registration once, also create your collection
> once
> and store it in a map.   Whenever you need it, get it from the
> singleton.   The only
> issue is when you close it...   You can close it everytime or leave it
> open and close
> it at the end of the program.   I leave mine open until I close the
> program.
> 
> Mark
> 
> Jinsuo Zhang wrote:
> 
> > On Mon, 25 Mar 2002, Mark J. Stang wrote:
> >
> > > This is either a bug or something you are doing wrong.   Can you
> > send
> > > a sample of the code so the list can try and determine which it is?
> > >
> > > Mark
> > >
> >
> > Hi, below is my code segment:
> >     Thanks for help.
> >
> > public class DBXMLProxy
> > {
> >
> >    public static String add_doc(String docname, String URI) throws
> > Exception {
> >       Collection col = null;
> >       String retval;
> >       try {
> >          String driver =
> > "org.apache.xindice.client.xmldb.DatabaseImpl";
> >          Class c = Class.forName(driver);
> >
> >          Database database = (Database) c.newInstance();
> >          DatabaseManager.registerDatabase(database);
> >          col =
> >
> > DatabaseManager.getCollection("xmldb:xindice:///db/mobiledata");
> >
> >          String data = readFileFromDisk(docname);
> >
> >          XMLResource document = (XMLResource) col.createResource(URI,
> >             "XMLResource");
> >          document.setContent(data);
> >          col.storeResource(document);
> >          retval = "1";
> >       }
> >       catch (XMLDBException e) {
> >          System.out.println("XML:DB Exception occured " + e.errorCode
> > + " " +
> >             e.getMessage());
> >          retval = null;
> >       }
> >       finally {
> >          if (col != null) {
> >             col.close();
> >          }
> >       }
> >       return retval;
> >    }
> >   ...
> >   similar routines to do xml related work
> >   ....
> >
> >    public static void main(String[] args) throws Exception
> >     {
> >       ...
> >       loop
> >       {
> >         get request from other programs, and call requested routine.
> >       }
> >      ...
> >    }
> > }
> >
> > --
> > Jinsuo Zhang
> >
> > CISE department
> > Univ of Florida
> 
> 

Reply via email to