Re: AW: [api-dev] url for new base document

2006-03-17 Thread Stephan Wunderlich

Hi Andreas,


thank you for your snippet - the document will be created. But i can not open 
the connection. I will always get the error 'No storage property was set'.

After restarting OpenOffice.org the connection is available.

Any idea ?


not sure if I understand you correctly ... I can work with this newly 
opened db-document ... create tables for example worked like a charm.


So what means i can not open the connection ?

Regards

Stephan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



AW: AW: [api-dev] url for new base document

2006-03-17 Thread Andreas Bröker
Hello Stephan,

was my mistake. Now it works.

Thank you.

Regards

Andreas

-Ursprüngliche Nachricht-
Von: Stephan Wunderlich [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 17. März 2006 10:34
An: dev@api.openoffice.org
Betreff: Re: AW: [api-dev] url for new base document

Hi Andreas,

 thank you for your snippet - the document will be created. But i can not open 
 the connection. I will always get the error 'No storage property was set'.
 
 After restarting OpenOffice.org the connection is available.
 
 Any idea ?

not sure if I understand you correctly ... I can work with this newly 
opened db-document ... create tables for example worked like a charm.

So what means i can not open the connection ?

Regards

Stephan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



AW: [api-dev] url for new base document

2006-03-16 Thread Andreas Bröker
Hello Stephan,

thank you for your snippet - the document will be created. But i can not open 
the connection. I will always get the error 'No storage property was set'.

After restarting OpenOffice.org the connection is available.

Any idea ?

Best regards

Andreas

-Ursprüngliche Nachricht-
Von: Stephan Wunderlich [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 16. März 2006 15:07
An: dev@api.openoffice.org
Betreff: Re: [api-dev] url for new base document

Hi Andreas,

 which url must i use in order to construct a new OpenOffice.org base 
 document with the java api.

Database Documents differ from other documents ... you need to define a 
datasource for them and they have to exist on your hard disk ... the 
following code should do what you want ...

--
XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();

XMultiComponentFactory xMCF = xContext.getServiceManager();

// create a new instance of the the desktop
Object oDesktop = xMCF.createInstanceWithContext(
com.sun.star.frame.Desktop, xContext );

// query the desktop object for the XComponentLoader
XComponentLoader xCLoader = ( XComponentLoader )
UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );

//create a new datasource

Object dataSource = xMCF.createInstanceWithContext(
com.sun.star.sdb.DataSource, xContext);

XPropertySet xSrcProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, dataSource);

xSrcProp.setPropertyValue(URL, sdbc:embedded:hsqldb);

XDocumentDataSource xDDS = (XDocumentDataSource)
UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);

XStorable store = (XStorable) UnoRuntime.queryInterface(
XStorable.class,xDDS.getDatabaseDocument());

String aFile = file:///wherever you want it/testdb.odb;


//store it
store.storeAsURL(aFile, new PropertyValue[] {  });

//load it again
xCLoader.loadComponentFromURL(
aFile, _blank, 0,  new PropertyValue[]{});
--

Hope that helps

Regards

Stephan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]