Issue 57664 - DataSource does not support XStorable interface
Summary: DataSource does not support XStorable interface
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: ocke.janssen
QA Contact: issues@api
URL:
Keywords:
: 57654 66271 (view as issue list)
Depends on:
Blocks:
 
Reported: 2005-11-10 11:59 UTC by alimaverde
Modified: 2013-02-24 21:09 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description alimaverde 2005-11-10 11:59:00 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();
}
Comment 1 stephan.wunderlich 2005-11-10 12:51:32 UTC
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.
Comment 2 Frank Schönheit 2005-11-10 12:57:29 UTC
*** Issue 57654 has been marked as a duplicate of this issue. ***
Comment 3 Frank Schönheit 2005-11-10 13:06:24 UTC
fs->oj: your chapter
Comment 4 ocke.janssen 2006-07-03 13:09:53 UTC
Change target.
Comment 5 ocke.janssen 2006-07-28 07:04:27 UTC
*** Issue 66271 has been marked as a duplicate of this issue. ***
Comment 6 ocke.janssen 2006-07-31 07:18:52 UTC
Fixed in cws jsc12.
Comment 7 jsc 2006-07-31 16:16:47 UTC
verified
Comment 8 ocke.janssen 2006-10-27 09:27:58 UTC
Closing