From: Christoph P. <spe...@gm...> - 2007-04-25 11:15:17
|
Hallo, i need again some help. i'm not completely sure but i think my application did yesterday the same operation without error. by the way i'm using the cvs/trunk version. if i use the client everything is fine and i can store up to 25MB xml-files (didn't tested with bigger ones) into eXist. but if i want to store a 1,6MB file out of my java application i get the networking error. with the client it works!!! so what can i do? some settings or a problem with the code (see below)? thanks for any advice and help, christoph public class ReadAndStore { public final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc"; private String fileName = ""; private String collectionName = "/db/"; private Collection col; private String errors; public ReadAndStore() { // initialize driver try { long time = System.currentTimeMillis(); String driver = "org.exist.xmldb.DatabaseImpl"; Class cl = Class.forName(driver); Database database = (Database)cl.newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); System.out.println("Done - connection to db!("+(System.currentTimeMillis()-time)+")"); } catch(Exception e) { if(errors != ""){errors = errors + " | ";} errors = errors + "(2) Driver not initialized!"; } } // no collection set, only filename --> default collection used public String doImport(String fileName) { errors = ""; this.fileName = fileName; importing(); return errors; } // use entered collection public String doImport(String collectionName, String fileName) { errors = ""; this.collectionName = collectionName; this.fileName = fileName; //System.out.println("a"+fileName); importing(); return ""+errors; } // reads and stores the data private void importing() { // test for wrong params if(fileName == "") { if(errors != ""){errors = errors + " | ";} errors = errors + "(1) No filename set!"; } // try to get collection try { col = DatabaseManager.getCollection(URI + collectionName); if(col == null) { Collection root = DatabaseManager.getCollection(URI + DBBroker.ROOT_COLLECTION); CollectionManagementService mgtService = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); col = mgtService.createCollection(collectionName.substring((DBBroker.ROOT_COLLECTION + "/").length())); } } catch(Exception e) { if(errors != ""){errors = errors + " | ";} errors = errors + "(3) Problems with the collection!"; } try { File f = new File(fileName); // create new XMLResource XMLResource document = (XMLResource)col.createResource(f.getName(), "XMLResource"); document.setContent(f); System.out.print("storing document " + document.getId() + "..."); col.storeResource(document); System.out.println("ok.\n"); } catch(Exception e) { System.out.println("!!"+e.getMessage()); if(errors != ""){errors = errors + " | ";} errors = errors + "(4) Problems saving the file! " + e.getMessage(); } } } -- Christoph Pahre "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail |