Apache OpenOffice (AOO) Bugzilla – Issue 57664
DataSource does not support XStorable interface
Last modified: 2013-02-24 21:09:05 UTC
Trying to add a new datasource using the code example from session 12.2.2 page 833 (Adding and Editing Datasources) result in NullPointeException. The line XStorable store = (XStorable)UnoRuntime.queryInterface(XStorable.class, xDs); Returns null. The code from developer guide: (I am using the RC2 release of the SDK and the final release of OpenOffice 2.0) // creates a new DataSource public static void createNewDataSource(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception { // the XSingleServiceFactory of the database context creates new generic // com.sun.star.sdb.DataSources (!) // retrieve the database context at the global service manager and get its // XSingleServiceFactory interface XSingleServiceFactory xFac = (XSingleServiceFactory)UnoRuntime.queryInterface( XSingleServiceFactory.class, _rMSF.createInstance("com.sun.star.sdb.DatabaseContext")); // instantiate an empty data source at the XSingleServiceFactory // interface of the DatabaseContext Object xDs = xFac.createInstance(); // register it with the database context XNamingService xServ = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, xFac); XStorable store = ( XStorable)UnoRuntime.queryInterface(XStorable.class, xDs); XModel model = ( XModel)UnoRuntime.queryInterface(XModel.class, xDs); store.storeAsURL(“file:///c:/test.odbâ€,model.getArgs()); xServ.registerObject("NewDataSourceName", xDs); // setting the necessary data source properties XPropertySet xDsProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDs); // Adabas D URL xDsProps.setPropertyValue("URL", "sdbc:adabas::MYDB1"); // force password dialog xDsProps.setPropertyValue("IsPasswordRequired", new Boolean(true)); // suggest dsadmin as user name xDsProps.setPropertyValue("User", "dsadmin"); store.store(); }
sw->alimaverde: the concept has changed slightly in OOo2.0, you can't get the XStorable interface directly at the datasource anymore, you'll have to do something like XDocumentDataSource xDDS = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, xDs); XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class, xDDS.getDatabaseDocument()); sw->fs: I think the devolopersguide should reflect this change.
*** Issue 57654 has been marked as a duplicate of this issue. ***
fs->oj: your chapter
Change target.
*** Issue 66271 has been marked as a duplicate of this issue. ***
Fixed in cws jsc12.
verified
Closing