database.setProperty("create-database", "true");
DatabaseManager.registerDatabase(database);
Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", "");
CollectionManagementService mgmt = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
Collection collection = mgmt.createCollection("protected");
IndexQueryService idxConf = (IndexQueryService) collection.getService("IndexQueryService", "1.0");
idxConf.configureCollection(COLLECTION_CONFIG);
XMLResource hamlet = (XMLResource) collection.createResource("hamlet.xml", "XMLResource");
hamlet.setContent(new File("samples/shakespeare/hamlet.xml"));