Dear Wiki user, You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.
The following page has been changed by KevinWilliams: http://wiki.apache.org/ws/Tuscany/TuscanyJava/DAS_Java_Overview/RDBDAS_Java_User_Guide/Basic_CRUD ------------------------------------------------------------------------------ = Basic CRUD = + == Reading Data == The RDB DAS provides a simple, command-oriented approach for reading and writing to the database. The following illustrates the simplest possible read: {{{ DAS das = DAS.FACTORY.createDAS(getConnection()); - Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1"); + Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 22590"); DataObject root = readCustomers.executeQuery(); }}} The first line creates an instance of the DAS that is primed with a given JDBC Connection object. The Connection can be procured in a number of different ways. This example is from the RDB DAS test suite and the implentation of getConnection()simply uses the !DriverManager.getConnection() method. + The second line uses the das instance as a factory to create a Command instance from the provided SQL SELECT string. The third line executes the command which returns a "root" SDO !DataObject. This root !DataObject is sometimes referred to as a "dummy" root and acts as a container for the graph of data returned from the query. The RDB DAS always returns a dummy root from executing a query. + + Once we have a handle to the root we can pull information from the returned customer object using the dynamic SDO apis like this: + {{{ + DataObject cust = root.getDataObject("CUSTOMER[1]"); + String name = cust.getString("LASTNAME"); + }}} + + The first line retreives the first Customer from the root's list of returned Customers (since we queried by ID, thereis only one). The second line pulls the LASTNAME value from the customer. + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
