Difference between revisions of "Documentation/DevGuide/Database/Catalog Service"
From Apache OpenOffice Wiki
< Documentation | DevGuide
(Initial author Sun Microsystems, Inc.) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/Database/Table Service | |NextPage=Documentation/DevGuide/Database/Table Service | ||
}} | }} | ||
− | {{DISPLAYTITLE:Catalog Service}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Database/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Catalog Service}} | ||
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 <idl>com.sun.star.sdbcx.XDataDefinitionSupplier</idl> and an existing connection object. The following code fragment lists tables in a database. | 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 <idl>com.sun.star.sdbcx.XDataDefinitionSupplier</idl> and an existing connection object. The following code fragment lists tables in a database. | ||
<!--[SOURCE:Database/sdbcx.java]--> | <!--[SOURCE:Database/sdbcx.java]--> | ||
− | + | <syntaxhighlight lang="java"> | |
// create the Driver with the implementation name | // create the Driver with the implementation name | ||
Object aDriver = xORB.createInstance("com.sun.star.comp.sdbcx.adabas.ODriver"); | Object aDriver = xORB.createInstance("com.sun.star.comp.sdbcx.adabas.ODriver"); | ||
Line 61: | Line 62: | ||
} | } | ||
} | } | ||
− | + | </syntaxhighlight> | |
{{PDL1}} | {{PDL1}} | ||
− | [[Category: Database Access]] | + | |
+ | [[Category:Documentation/Developer's Guide/Database Access]] |
Latest revision as of 15:06, 21 December 2020
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 com.sun.star.sdbcx.XDataDefinitionSupplier 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("com.sun.star.comp.sdbcx.adabas.ODriver"); // query for the interface com.sun.star.sdbc.XDriver 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 com.sun.star.beans.PropertyValue [] adabasProps = new com.sun.star.beans.PropertyValue[] { new com.sun.star.beans.PropertyValue("user", 0, "test1", com.sun.star.beans.PropertyState.DIRECT_VALUE), new com.sun.star.beans.PropertyValue("password", 0, "test1", com.sun.star.beans.PropertyState.DIRECT_VALUE) }; // 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++) System.out.println(aTableNames[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) { xComponent.dispose(); 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). |