|
From: <rga...@us...> - 2002-12-30 23:55:44
|
Update of /cvsroot/csms/csms-core/src/java/org/fanfoot/db
In directory sc8-pr-cvs1:/tmp/cvs-serv18431
Modified Files:
DB.java
Log Message:
Add basic support for XML:DB databases
Index: DB.java
===================================================================
RCS file: /cvsroot/csms/csms-core/src/java/org/fanfoot/db/DB.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DB.java 21 Nov 2002 22:21:48 -0000 1.2
--- DB.java 30 Dec 2002 23:55:41 -0000 1.3
***************
*** 44,47 ****
--- 44,48 ----
import org.xmldb.api.modules.XMLResource;
import org.xmldb.api.modules.XPathQueryService;
+ import org.xmldb.api.modules.XUpdateQueryService;
/**
* Provides utility methods for accessing the DB
***************
*** 74,79 ****
* Query the indicated collection with the XPath query supplied.
*
- *@param strQuery XPath query to run
*@param strCollection Description of the Parameter
*@return
*@throws DBException if unable to query the database
--- 75,80 ----
* Query the indicated collection with the XPath query supplied.
*
*@param strCollection Description of the Parameter
+ *@param strQuery XPath query to run
*@return
*@throws DBException if unable to query the database
***************
*** 105,108 ****
--- 106,145 ----
return resultSet;
+ }
+
+
+ /**
+ * XUpdate the indicated collection with the XUpdate modificatons
+ * supplied.
+ *
+ *@param strCollection Description of the Parameter
+ *@param strUpdate XUdpate modifications to run
+ *@throws DBException if unable to update the database
+ */
+ public void runXUpdateQuery( String strCollection, String strUpdate )
+ throws DBException {
+ Collection col = getCollection( strCollection );
+ XUpdateQueryService service;
+ ResourceSet resultSet;
+ try {
+ service =
+ (XUpdateQueryService) col.getService( "XUpdateQueryService", "1.0" );
+ } catch ( XMLDBException xde ) {
+ throw new DBException( "Unable to get XUpdateQueryService", xde );
+ }
+ try {
+ service.update( strUpdate );
+ } catch ( XMLDBException xde ) {
+ throw new DBException( "Unable to execute XPath Query", xde );
+ } finally {
+ if ( col != null ) {
+ try {
+ col.close();
+ } catch ( XMLDBException xde ) {
+ // FIXME handle this error, it is not critical but will be a memory leak
+ logger.log( Level.WARNING, "Unable to close connection", xde );
+ }
+ }
+ }
}
|