Hey, Dick.  Yes, it is possible to return a ResultSet from Java to
ColdFusion MX.  Below is a Java class which performs a simple query
against a Postgresql database, and returns the ResultSet:

public class DatabaseTest
{
    public ResultSet getPasswords()
    {
        ResultSet passwords = null;
        try
        {
            Class.forName("org.postgresql.Driver");
            Connection con =
           DriverManager.getConnection("jdbc:postgresql://127.0.0.1/dbname",
                                            "username",
                                            "password");
            Statement s = con.createStatement();
            passwords = s.executeQuery("select password from userdef");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return passwords;
    }
}

Below is a ColdFusion page that handles the ResultSet:

<html>
    <cfobject type="Java"
              action="create"
              class="DatabaseTest"
              name="dbtest">
    <!--- the passwords var will be a ResultSet object --->
    <cfset passwords = dbtest.getPasswords() />

    <cfoutput query="passwords">#password#<br /></cfoutput>
</html>

I hope this answers your question.

Cantrell

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to