5 Replies Latest reply on Sep 30, 2016 8:47 AM by shawkins

    Execute connector methods directly

    tomesc

      Hi,

      I would like to execute the implemented methods of a certain teiid connector directly, without defining VDB or using a Datasource or JDBC connection. Did someone do this? Is there an example available or would you share sample code (connection and execution of a function)?

      Very thanks in advance.

      Thomas

        • 1. Re: Execute connector methods directly
          shawkins

          Connections are not required for a translator.  This can be declared by calling setSourceRequired(false) in the translator constructor.

           

          If you functions are static, then more than likely they should added as UDFs and not tied to a particular translator.  Are you trying to expose functions or stored procedures?

          • 2. Re: Execute connector methods directly
            tomesc

            Steven, thank you for your prompt reply. Maybe I should have expressed myself more clearly. I do not want to execute a SQL function or procedure. Instead I want to use a method that is defined in the connector (the implementation class of BasicConnection), or in my case SalesforceConnectionImpl. The Salesforce API provide a "upsert()" method (combination of insert/update) which is very useful in some circumstances (especially in cloud computing). So my intention is to extend the Salesforce connector with an "upsert" method and call that method directly. I thought of something like that:

             

            Context ctx = new InitialContext();

            org.teiid.resource.spi.WrappedConnectionFactory wrapper = ctx.lookup("java:/salesforceDS");  // jndi-name of resource adapter connection

            Connection con = wrapper.getConnection();

            ... and so on.

             

            But I have no idea how to cast it to the SalesforceConnectionImpl class to reach the methods. Or is there an error in my reasoning? Since I am new in TEIID I don't know if that all is possible using UDF's.

            Thomas

            • 3. Re: Execute connector methods directly
              shawkins

              There is an existing issue: [TEIID-3630] Support merge statement pushdown - JBoss Issue Tracker that would allow Teiid to pushdown a merge statement directly.  That is probably the preferred solution.

               

              To do this on your own you have to fork / extend the SalesforceConnection / SalesforceConnectionImpl to expose the upsert call, then utilize that in an extended translator - which would initially only work through the direct query procedure.

               

              Can you add a subtask to TEIID-3630 specifically for Salesforce?

              • 4. Re: Execute connector methods directly
                tomesc
                • 5. Re: Execute connector methods directly
                  shawkins

                  Thanks.  We should be able to get this into 9.2.