XMultiServiceFactory xMSF = (XMultiServiceFactory) Param.getMSF();
XNameAccess xNameAccess = null;
// we use the first datasource
XDataSource xDS = null;
try {
xNameAccess = (XNameAccess) UnoRuntime.queryInterface(
XNameAccess.class,
xMSF.createInstance("com.sun.star.sdb.DatabaseContext"));
} catch (Exception ex) {
ex.printStackTrace( log );
throw new StatusException( "Could not get Databasecontext", ex );
}
try {
xDS = (XDataSource) UnoRuntime.queryInterface(
XDataSource.class, xNameAccess.getByName( "Bibliography" ));
} catch (NoSuchElementException ex) {
ex.printStackTrace( log );
throw new StatusException( "Could not get XDataSource", ex );
} catch (WrappedTargetException ex) {
ex.printStackTrace( log );
throw new StatusException( "Could not get XDataSource", ex );
}
try {
xNameAccess = (XNameAccess) UnoRuntime.queryInterface(
XNameAccess.class,
xMSF.createInstance("com.sun.star.sdb.DatabaseContext"));
} catch (Exception ex) {
ex.printStackTrace( log );
throw new StatusException( "Could not get DatabaseConext", ex );
}
log.println("check XMultiServiceFactory");
try {
xConn = xDS.getConnection(new String(), new String());
} catch (SQLException ex) {
ex.printStackTrace( log );
throw new StatusException( "Could not get XConnection", ex );
}