TUSCANY-1465 is the JIRA which added index to the <ResultDescriptor> With that the physical order can be anything for <ResultDescriptor> as long as index is used properly. This JIRA helps in specifying result descriptor programmatically (i.e. not thru config file). See DynamicResultDescriptorTests.java and http://incubator.apache.org/tuscany/explicit-resultset-shape-definition.html . This feature is part of latest DAS release - beta2.
Prior to this fix, there was no index and as you say order is what matters and not name in <ResultDescriptor.> As there is a column named ID in table CONTACTs, DAS following conventions uses it as PK, now if it is really not unique in the database, it can cause problems in DB->DataObject xfer. e.g. if you have 2 rows having ID=1, and do select * from contact, then, the data graph obtained by DAS will not be able to show both rows in its data objects. For using SQL Server 2005 express edition provided db metadata - came across this url - http://forum.java.sun.com/thread.jspa?threadID=704004&tstart=150 So looks like there are some problems in the support when it comes to supporting resultsetmetadata. What needs to be working is - getTableName(idx), getSchemaName(idx), getColumnCount(), getColumnType(idx), getColumnName(idx). If all these are working, then DAS will be able to use the db metadata and will not need extra specification of ResultDescriptor in config file. So, you can check if some driver for SQL Server is supporting all these APIs and if you can use it. In that case, the <ResultDecriptor> can go away. Please let me know if this helps. Regards, Amita On 11/1/07, Jason Clark <[EMAIL PROTECTED]> wrote: > > As a follow up, I wrote a simple class to test this. > > Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); > String conUrl = "jdbc:sqlserver://****************" > Connection con = DriverManager.getConnection (conUrl); > > try { > Statement st = con.createStatement(); > ResultSet rs = st.executeQuery("SELECT * FROM CONTACTS"); > ResultSetMetaData md = rs.getMetaData(); > int col = md.getColumnCount(); > System.out.println("Number of Column : " + col); > System.out.println("Columns Name: "); > for (int i = 1; i <= col; i++) { > String col_name = md.getColumnName(i); > System.out.println(col_name); > } > } > > This successfully returned metadata about my table. > > If I do this... > > <Command name="all contacts" SQL="select * from CONTACTS" kind="Select"> > > <ResultDescriptor columnName="ID" tableName="CONTACTS" > columnType="commonj.sdo.Int"/> > > <ResultDescriptor columnName="FIRST_NAME" tableName="CONTACTS" > columnType="commonj.sdo.String"/> > > <ResultDescriptor columnName="LAST_NAME" tableName="CONTACTS" > columnType="commonj.sdo.String"/> > > <ResultDescriptor columnName="MIDDLE_NAME" tableName="CONTACTS" > columnType="commonj.sdo.String"/> > > </Command> > > I can then grab those columns, but I did notice the order is important and > the column name has nothing to do with the actual column name, it just > says > that the name you query the data object with is the word FIRST_NAME. It > could be monkey, it doesn't matter. Not a problem though, but I can't > figure > out why I need result descriptors if I ResultSet.getMetaData () in fact > returns the correct information. > > Any ideas? > > Thanks. > > -Jason > > > -----Original Message----- > > From: Luciano Resende [mailto:[EMAIL PROTECTED] ] > > Sent: Tuesday, October 30, 2007 6:39 PM > > To: [email protected] > > Subject: Re: DAS configuration must specify ResultDescriptors > > > > There are some databases that does not return metadata information, > > and DAS need that to build the result SDO Graph.More info on > > ResultDescriptor here [1]. > > > > What database are you using ? > > > > [1] http://incubator.apache.org/tuscany/explicit-resultset-shape- > > definition.html > > > > On 10/30/07, Jason Clark < [EMAIL PROTECTED]> wrote: > > > I'm getting the following exception when trying to implement simple > DAS > > CRUD > > > operations. > > > > > > Exception in thread "main" java.lang.RuntimeException: Unable to > obtain > > > table information from JDBC. DAS configuration must specify > > > ResultDescriptors > > > at > > > > > org.apache.tuscany.das.rdb.graphbuilder.impl.ResultMetadata.<init>(ResultM > > et > > > adata.java:81) > > > at > > > > > org.apache.tuscany.das.rdb.graphbuilder.impl.GraphBuilderMetadata > .<init>(G > > ra > > > phBuilderMetadata.java :69) > > > at > > > > > org.apache.tuscany.das.rdb.impl.ReadCommandImpl.buildGraph > (ReadCommandImpl > > .j > > > ava:295) > > > at > > > > > org.apache.tuscany.das.rdb.impl.ReadCommandImpl.executeQuery(ReadCommandIm > > pl > > > .java:277) > > > at ContactDASTest.getContacts(ContactDASTest.java:22) > > > at ContactDASTest.printContacts(ContactDASTest.java:28) > > > at ContactDASTest.main(ContactDASTest.java:41) > > > > > > > > > > > > Given the following config. I tried following the Company example and > > their > > > config. > > > > > > I'm unsure what a ResultDescriptor is and why I would need one, but > the > > > Company example does not. > > > > > > As a side note, my table is all strings stored in nvarchar columns. Is > > that > > > part of the issue? > > > > > > It also does not have a primary key at the moment, but I'm not sure > why > > that > > > would be a problem. > > > > > > > > > <Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> > > > > > > <!--ConnectionInfo dataSource="java:comp/env/jdbc/dastest"/--> > > > > > > <ConnectionInfo> > > > <ConnectionProperties > > > > > > driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver" > > > > databaseURL="jdbc:sqlserver://*;databasename=*" > > > userName="*" > > > password="*" > > > loginTimeout="600"/> > > > </ConnectionInfo> > > > > > > <Command name="all contacts" SQL="select * from CONTACTS" > > > kind="Select"/> > > > > > > <Table tableName="CONTACTS"> > > > > > > </Table> > > > > > > </Config> > > > > > > > > > -Jason Clark > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > Luciano Resende > > Apache Tuscany Committer > > http://people.apache.org/~lresende > <http://people.apache.org/%7Elresende> > > http://lresende.blogspot.com/ > > > > --------------------------------------------------------------------- > > 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] > >
