1 2 Previous Next 16 Replies Latest reply on May 15, 2014 6:34 AM by 724150880

    jboss + teiid  acess to datasource by ODBC

    724150880

      hi :

        i'm using jboss AS 7.1 +teiid 8.2 .and i have tested datasource by the way jdbc. now i use ODBC to access to datasource . but i found that the parameter partialResultsMode=true doesn't work . i want to know if there is another parameter can work in ODBC. i want to come true the function of partialResultsMode=true. or do you have some method to resolve the problem .follows is my OBDC code:

               

                  OdbcConnection conn = new System.Data.Odbc.OdbcConnection("DSN=PostgreSQL35W;UID=user;PWD=user");

                  OdbcCommand cmd = new OdbcCommand("select * from test", conn);

                  conn.Open();

                  OdbcDataReader myReader = cmd.ExecuteReader();

                  while (myReader.Read())

                  {

                      Console.Write(myReader.GetString(0)+" ");

                      Console.WriteLine(myReader.GetString(1));

                  }

                  Console.ReadLine();

        • 1. Re: jboss + teiid  acess to datasource by ODBC
          rareddy

          You can do


          OdbcCommand cmd = new OdbcCommand("SET partialResultsMode", "true");


          before running the your query.


          For more information on SET Command see SET Statement - Teiid 8.7 (draft)

          1 of 1 people found this helpful
          • 2. Re: jboss + teiid  acess to datasource by ODBC
            shawkins

            The pg driver logic typically only sends well know parameters pg when connecting.  Something Teiid specific that is applicable via a set statement would need to be done after the connection as Ramesh shows or as part of an initialization string if the client supports it.

            • 3. Re: Re: jboss + teiid  acess to datasource by ODBC
              724150880

              thanks Ramesh Reddy, i tried it as you said . and follow is my code .

               

              namespace ConsoleApplication1

              {

                  class Program

                  {

                      static void Main(string[] args)

                      {

                          OdbcConnection conn = new System.Data.Odbc.OdbcConnection("DSN=PostgreSQL35W;UID=user;PWD=user;");

                        OdbcCommand cod = new OdbcCommand("SET partialResultsMode=true", conn);

                        // OdbcCommand cod = new OdbcCommand("execute SET partialResultsMode=true", conn);

                          OdbcCommand cmd = new OdbcCommand("select * from test", conn);

                          conn.Open();

                          OdbcDataReader myR = cod.ExecuteReader();

                          OdbcDataReader myReader = cmd.ExecuteReader();

                          while (myReader.Read())

                          {

                              Console.Write(myReader.GetString(0)+" ");

                              Console.WriteLine(myReader.GetString(1));

                          }

                          Console.ReadLine();

                      }

                  }

              }

               

              but i occured error ,and there is no output.  the error is :

              {"ERROR [50000] ERROR: TEIID31100 Parsing error: Encountered \"[*]SET[*] partialResultsMode=\" at line 1, column 1.\nWas expecting: \"alter\" | \"call\" | \"create\" | \"delete\" | \"drop\" | \"exec\" | \"execute\" | \"insert\" | \"select\" | \"table\" ...\norg.teiid.jdbc.TeiidSQLException: TEIID31100 Parsing error: Encountered \"[*]SET[*] partialResultsMode=\" at line 1, column 1.\nWas expecting: \"alter\" | \"call\" | \"create\" | \"delete\" | \"drop\" | \"exec\" | \"execute\" | \"insert\" | \"select\" | \"table\" ...;\nError while executing the query"}


              i dont't know where is wrong.

              • 4. Re: Re: jboss + teiid  acess to datasource by ODBC
                shawkins

                Use "SET partialResultsMode true" without the =.

                • 5. Re: Re: jboss + teiid  acess to datasource by ODBC
                  724150880

                  thanks Steven Hawkins very much ,i was successful . and i want to know if we can set the parameter in sever configuration ,eg. standalone-teiid.xml ? i suppose that  the parameter partialResultsMode maybe affect something or activate some actions  in server。

                  • 6. Re: Re: jboss + teiid  acess to datasource by ODBC
                    rareddy

                    Currently that is not possible.

                     

                    @Steve: I believe we need to go with your suggestion of adding the execution properties to vdb.xml as supported properties as this seems to be much more useful to configure them at vdb level.

                     

                    Ramesh..

                    • 7. Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                      724150880

                      i am so sorry to bother you again . i encounter a very strange problem .  i create a vdb whose name is myvdb, cotains a multi-source model:mysqlvdb , and in the model ,the first datasource is mysql89DS , the second datasource is mysql90DS.  and after i set the parameter partialResultsMode=true , if the first is down , it works well , but if the second is down , it will occur error: Exception thrown org.teiid.jdbc.TeiidSQLException: Remote org.teiid.api.exception.query.QueryResolverException: Group does not exist: PC90  when i execute query by JDBC or ODBC.

                      • 8. Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                        rareddy

                        When you are deploying the VDB (I am guessing you are using dynamic VDB) there should be at least one datasource available, to read in the metadata. After that it should be fine if one or both sources are down. I am suspecting when you deployed the VDB both your sources are down, is it?

                         

                        Also for multi-source to work both schema need to be identical, they can not have different tables names with different schema names in both databases.

                         

                        Ramesh..

                        • 9. Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                          724150880

                          yes , i am using dynamic VDB. and i tried that one of the datasources is down , it will work .  but for tables in schema, if the first datasource  has a table PC89 which the second doesn't have . when we execute query "select * from PC89 " ,it can get correct result .  but in reverse , if the second has table PC90 which the first doesn't have ,when we execute query "select * from PC90 " ,it will occur the error above. by the way , if we create a new table test in a datasource , it will not recognise the new table in vdb until we edit the vdb file :mysqltest-vdb.xml (vim mysqltest-vdb.xml

                          and save and quit by :wq) . it seems that after the vdb file have changed , it will trigger the vdb reload again.and is there other methods to trigger the vdb reload to recognise the new table ?

                          • 10. Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                            shawkins

                            > if the second has table PC90 which the first doesn't have ,when we execute query "select * from PC90 " ,it will occur the error above.


                            Yes, the current assumption is that the metadata is the same across multi-source sources, so metadata is only loaded from 1 source.


                            > is there other methods to trigger the vdb reload to recognise the new table ?


                            A redeploy through the admin deploy method, or an admin restart with the restartVDB method.

                            • 11. Re: Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                              724150880

                              i'am confused about multi-source sources .it seems that if we use multi-source sources, all of the metadata must be the same type(ie. all is mysql) . if we use different types of metadata ,we must create several single-source models. and in several single-source models , we use query only by " select id,name from  (select id ,name from model1.test union all select id ,name from model2.test) e"  instead of  select id,name from test. am i right? 

                              • 12. Re: Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                                rareddy

                                The ability of the data virtualization does end with multi-source or querying the single sources under a VDB.  If you choose to import metadata from each individual source, then the metadata can be different in each of the source. Then you can create VIRTUAL models (schemas) using JBDS. In virtual models you can define Virtual Tables or Views that can be derived from different tables from different sources.

                                 

                                For example you TableOne in ModelOne, and TableTwo in ModelTwo, then you can create a virtual model and have a CombinedTable that UNIONS both the TableOne and TableTwo. Then you can simply issue "select * from CombinedTable". Look at quick starts Data Federation Example

                                 

                                Also, you do not have to create virtual models before you can integrate data from two separate models, you can do what you showed above like select id,name from  (select id ,name from model1.test union all select id ,name from model2.test) e" from client. However, if you would like to create abstraction/logical layer between your client code and physical sources, virtual models is the way to go.

                                 

                                Ramesh..

                                • 13. Re: Re: Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                                  724150880

                                  > If you choose to import metadata from each individual source, then the metadata can be different in each of the source.


                                  how can i import metadata from each individual source in a multi-source model? follow is my vdb configuration:

                                  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

                                  <vdb name="myvdb" version="1">

                                  <description>A Mysql VDB</description>

                                  <property name="UseConnectorMetadata" value="true" />

                                  <model visible="true" type="PHYSICAL" name="mysqlvdb">

                                          <property name="supports-multi-source-bindings" value="true"/>

                                          <property name="importer.useFullSchemaName" value="true"/>

                                          <source name="mysql89" translator-name="mysql5" connection-jndi-name="java:mysql89DS"/>

                                          <source name="mysql90" translator-name="mysql5" connection-jndi-name="java:mysql90DS"/>

                                  </model>

                                  </vdb>

                                  • 14. Re: Re: Re: Re: Re: Re: jboss + teiid  acess to datasource by ODBC
                                    shawkins

                                    > how can i import metadata from each individual source in a multi-source model?


                                    You currently cannot in a built-in way.  The underlying assumption is that the sources are the same.  To do what you want, there are a couple of possibilities:


                                    1. Use different models for each source and manually create the multi-source views:


                                    create view test_ms as select id ,name, 'model1' as SOURCE_NAME from model1.test union all select id ,name, 'model2' from model2.test


                                    Then you can issue queries against test_ms similar to the multi-source scenario: 

                                    "select * from test_ms" - goes to both sources

                                    "select * from test_ms where source_name = 'model1'" - goes to just the model1 source


                                    2. Use a multi-source model, and single source models.

                                     

                                    Using the importer schema/table pattern or excludeTables settings you could have a model that represents just the tables that are present in all sources, then add additional models that represent just the single source table from each source.  There could be some downside here in that the optimizer may not be able to fully optimize some scenarios that utilize both the multi-source and single-source models.

                                     

                                    3. Still use the multi-source concept, but create a custom translator that will return a super set of the metadata rather than just the metadata for the first available source.  This requires extending a translator or using a delegating translator that would look at the Model on the MetadataFactory to determine the sources and interrogate each one.  However this will not work very well as the optimizer will assume that a multi-source single source table is available on each source, so you may generally not get the results you expect unless the query is specifically targeted at the source containing all of the tables in the query.

                                    1 2 Previous Next