• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Create a CF Query Result Set in Java

New Here ,
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

I'd like to programatically build a ColdFusion query resultset inside of a Java class and return it to the calling application.  See the Java psudocode below to see what I'm talking about:

public class MyClass {

     public coldfusion.sql.QueryTable getQuery() {

          // Create a query table object

          QueryTable myTable = ..?

          // Loop through some set of instance data for my class

          for(int c = 0; c < this.myWigets.length; c++) {

               int row = c+1;

               myTable.setField(row, nameCol, this.myWigets.name);

               myTable.setField(row, colorCol, this.myWigets.color);

          }

          return myTable;

     }

}

I've had stuff like this partially working in the past but had issues with things like query of queries and such probably due to the hacks used to create the QueryTable object.  I'm mainly just checking in to see if there has been any progress made in this area.  To me this seems like such an obvious thing for a Java developer working within CF to want to do.  I'm surprised Adobe doesn't have an officially supported API for doing this sort of thing (or maybe I'm just too dumb to find it.)    A few other notes... I'm not using CFX, and I'm not starting with a java.sql.ResultSet otherwise I would use the QueryTable(java.sql.ResultSet) constructor.  I need to build this thing from scratch programatically.

Thanks for your time.  I hope this question makes sense to someone out there.

- Mike

TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

I think it would be a lot easier to write a webservice with cfml and call it with java.  By the way, this calling application that needs a cfquery object, is it cold fusion?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

I appologize.  I wasn't very clear with my original question.

I'm creating an instance of my Java class from within CF using createObject("java", "com.example.MyClass").  So based on the sample code in my original post on the CF side I'd like to do something like this:


<cfscript>

     myObj = createObject("java", "com.example.MyClass");

     myObj.doSomeStuff();

     myCFQuery = myObj.getQuery();  // Return a CF query from my java class

</cfscript>

... then do stuff like ...

<cfquery name="mySortedQuery" dbtype="query">

     select     *

     from       myCFQuery

     order      by color

</cfquery>

I appriciate your suggestions so far.  I have other solutions working already but they are not ideal.  I was just hoping someone had a clean and as-hack-free-as-possible way of creating a ColdFusion query result set in Java and passing it back to CF.

Thanks again,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 03, 2009 Aug 03, 2009

Copy link to clipboard

Copied

LATEST

I do not think there is a documented api, other than the one for cfx tags.  Though I would love to see one myself ..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation