Connectionprobleme mit Xindice

Status
Nicht offen für weitere Antworten.
G

Guest

Gast
Hallo,

ich möchte mich auf eine XML-Datenbank verbinden.
Hier ist mein Code:


Code:
package Xml;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

import java.io.*;

public class Testclass {

	public static void main(String[] args) throws Exception {
		Collection col = null;

		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://localhost:8080/db/");

		String data = readFileFromDisk("c:\\build.xml");

		XMLResource document = (XMLResource) col.createResource(null,
				"XMLResource");
		document.setContent(data);
		col.storeResource(document);
		System.out.println("Document " + "c:\\build.xml" + " inserted");

		if (col != null) {
			col.close();
		}

	}

	public static String readFileFromDisk(String fileName) throws Exception {
		File file = new File(fileName);
		FileInputStream insr = new FileInputStream(file);

		byte[] fileBuffer = new byte[(int) file.length()];

		insr.read(fileBuffer);
		insr.close();

		return new String(fileBuffer);
	}
}

Wenn ich das Program starte, erhalte ich folgende Fehlermeldung:

Exception in thread "main" org.xmldb.api.base.XMLDBException:
at org.xmldb.api.DatabaseManager.getDatabase(DatabaseManager.java:258)
at org.xmldb.api.DatabaseManager.getCollection(DatabaseManager.java:190)
at org.xmldb.api.DatabaseManager.getCollection(DatabaseManager.java:157)
at Xml.Testclass.main(Testclass.java:20)


Kannn mir jemand helfen?

Gruß
 
G

Guest

Gast
Nein mehr steht da nicht.
Ja ich habe den Xindice über Tomcat eingebunden. Und im Tomcat steht, dass die Datenbank gestartet ist und ich kann über Tomcat auch auf die Datenbank zugreifen.

Gruß
 
G

Guest

Gast
Fragt mich nicht warum, aber ich habe eine andere Fehlermeldung erhalten


trying to register database
org.xmldb.api.base.XMLDBException: Cannot communicate with the server: http://localhost:4080/xindice/
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(CollectionImpl.java:127)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.<init>(CollectionImpl.java:88)
at org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl.getCollection(DatabaseImpl.java:354)
at org.apache.xindice.client.xmldb.DatabaseImpl.getCollection(DatabaseImpl.java:137)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at Xml.Testclass.main(Testclass.java:21)
Caused by: java.io.IOException: Connection refused: connect
at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(CollectionImpl.java:112)
... 5 more
[B@161d36bjava.io.IOException: Connection refused: connect
at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(CollectionImpl.java:112)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.<init>(CollectionImpl.java:88)
at org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl.getCollection(DatabaseImpl.java:354)
at org.apache.xindice.client.xmldb.DatabaseImpl.getCollection(DatabaseImpl.java:137)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at Xml.Testclass.main(Testclass.java:21)
Caused by: java.io.IOException: Connection refused: connect
at org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.runRemoteCommand(CollectionImpl.java:112)
at org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.<init>(CollectionImpl.java:88)
at org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl.getCollection(DatabaseImpl.java:354)
at org.apache.xindice.client.xmldb.DatabaseImpl.getCollection(DatabaseImpl.java:137)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at Xml.Testclass.main(Testclass.java:21)
Exception in thread "main"
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Oben