Hey Christian

Thanks, that's  exactly what I want --

I had to add the following to the beginning of the Java program to get  
it to recognize "ResultSet".

Between you, Joe & Jochem, I am on my way!

Thanks!

Dick


On Saturday, November 30, 2002, at 03:32 PM, Christian Cantrell wrote:

> 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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to