Catalog Service

From Apache OpenOffice Wiki
Jump to: navigation, search

The Catalog object is the highest-level container in the SDBCX layer. It contains structural features of databases, like the schema and security model for the database. The connection, for instance, represents the database, and the Catalog is the database container for the tables, views, groups, and users within a connection or database. To create a catalog object, the database driver must support the interface and an existing connection object. The following code fragment lists tables in a database.

  // create the Driver with the implementation name
  Object aDriver = xORB.createInstance("");
  // query for the interface xDriver;
  xDriver = (XDriver)UnoRuntime.queryInterface(XDriver.class, aDriver);
  if (xDriver != null) {
      // first create the needed url
      String adabasURL = "sdbc:adabas::MYDB0";
      // second create the necessary properties [] adabasProps = new[] {
          new"user", 0, "test1",
          new"password", 0, "test1",
      // now create a connection to adabas
      XConnection adabasConnection = xDriver.connect(adabasURL, a dabasProps);
      if(adabasConnection != null) {
          System.out.println("Connection could be created!");
          // we need the XDatabaseDefinitionSupplier interface 
          // from the driver to get the XTablesSupplier
          XDataDefinitionSupplier xDDSup = (XDataDefinitionSupplier)UnoRuntime.queryInterface(
              XDataDefinitionSupplier.class, xDriver);
          if (xDDSup != null) {
              XTablesSupplier xTabSup = xDDSup.getDataDefinitionByConnection(adabasConnection);
          if (xTabSup != null) {
              XNameAccess xTables = xTabSup.getTables();
              // now print all table names
              System.out.println("Tables available:");
              String [] aTableNames = xTables.getElementNames();
              for ( int i =0; i<= aTableNames.length-1; i++)
          else {
              System.out.println("The driver is not SDBCX capable!");
          // now we dispose the connection to close it
          XComponent xComponent = (XComponent)UnoRuntime.queryInterface(
              XComponent.class, adabasConnection);
          if (xComponent != null) {
              System.out.println("Connection disposed!");
      else {
          System.out.println("Connection could not be created!");
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages