Hi Everybody,
I am using Xindice 1.1 the database which is running under Tomcat 4.1.12. Also my java version is 1.3.1.
When I create a collection from a different context other than Xindice, it produces an Error:
XML:DB Exception occured org.xmldb.api.base.XMLDBException: A connection to the
Database instance 'db' could not be created. Error: .
Pls send me the solution. My code is given below: ======================================================================
import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
import org.xmldb.api.base.*; import org.xmldb.api.modules.*; import org.xmldb.api.*;
// For the Xindice specific CollectionManager service import org.apache.xindice.client.xmldb.services.*;
import org.apache.xindice.xml.dom.*;
public class CreateCollection extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
org.xmldb.api.base.Collection col = null;
try {
String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
org.xmldb.api.DatabaseManager.registerDatabase(database);
col =
org.xmldb.api.DatabaseManager.getCollection("xmldb:xindice://./db/");
String collectionName = "mycollection";
CollectionManager service =
(CollectionManager) col.getService("CollectionManager", "1.0");
// Build up the Collection XML configuration.
String collectionConfig =
"<collection compressed=\"true\" name=\"" + collectionName + "\">" +
" <filer class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"true\"/>" +
"</collection>";
service.createCollection(collectionName, DOMParser.toDocument(collectionConfig));
System.out.println("Collection " + collectionName + " created."); } catch (XMLDBException e) { System.err.println("XML:DB Exception occured " + e.toString()); } catch (Exception exp) { System.err.println("XML:DB Exception occured " + exp.toString()); } finally { try { if (col != null) { col.close(); } } catch (XMLDBException e) { System.err.println("XML:DB Exception occured " + e.toString()); } catch (Exception exp) { System.err.println("XML:DB Exception occured " + exp.toString()); } } } }
Avik
_________________________________________________________________
Taureans! See what's in store. http://server1.msn.co.in/features/taurus/index.asp Have a great year!