CFSQLTool on http://cfopen.org/projects/cfsqltool/ demos several
techniques for building queries within a CFC.
It uses the cffactory to get DSNs. It's open source so you can see
many details.
The technique in the code generated by the tool uses
pass-by-reference structures as parameters for the query functions.
Some programmers like using pass-by-value and building long parameter
lists whereas passing a structure simplifies the function. The tools
code wizards generate all this for you, so building a CFC for queries
is simple.
- - CFSQLTool code builds data access layer (DAL) CFCs. Data access
objects are treated as an abstraction to the DAL and implemented as a
service CFC. Data access layers can be for database queries, form
queries, URL queries, etc. So, for example, an update method to a
database or an update to a form is mechanism of the the layer's
objects but from the application both are updates but with different
data structures.
Joseph
At 02:46 PM 10/25/2005, you wrote:
This probably isn't supported by Macromedia but it appears to work:
<cfset datasource = "quickstart" />
<cfset connection = createObject("java",
"coldfusion.server.ServiceFactory").getDataSourceService().getDatasource(datasource).getConnection())
/>
<cfdump var="#connection#" />
<cfset connection.close() />
On 10/25/05, Barney Boisvert <[EMAIL PROTECTED]> wrote:
> I was actually thinking about one step further, where you actually get
> the connection from CF's pool, rather than just the connection info.
> So you let CF take care of everything (as it does normally), except
> that you have complete control over the connection rather than letting
> CF manage it. And really, my greater hope would be for that
> functionality on BD, because it'd alleviate some of the
> transaction-related issues it has (not bugs, per se, just
> implementation details that prevent certain solutions from working).
> But if it worked cross platform (with a check for the server to tell
> how to get the connection, of course), that'd be the best scenario.
>
> cheers,
> barneyb
>
> On 10/25/05, Doug Arthur <[EMAIL PROTECTED]> wrote:
> > Just to slightly modify what I've already done, is this what you're
> > refereing to Barney?
> >
> > The only downside is that since the password is encrypted in
the structure,
> > the password would still have to be supplied.
> >
> > <cffunction name="dump">
> > <cfdump var="#Arguments[1]#">
> > </cffunction>
> > <cfscript>
> > namedDatasource = "db";
> > password = "password";
> >
> >
> > ServiceFactory = CreateObject("java",
> > "coldfusion.server.ServiceFactory");
> > datasources =
> > ServiceFactory.getDataSourceService().getDatasources();
> >
> > if(StructKeyExists(datasources, namedDatasource))
> > dataSourceStruct = StructFind(datasources, namedDatasource);
> >
> >
> > try {
> > Class =
> > createObject("java","java.lang.Class").forName(dataSourceStruct.class);
> > DriverManager = createObject("java", " java.sql.DriverManager");
> > conn = DriverManager.getConnection(dataSourceStruct.url,
> > dataSourceStruct.username, password);
> > stmt = conn.createStatement();
>
>
> --
> Barney Boisvert
> [EMAIL PROTECTED]
> 360.319.6145
> http://www.barneyb.com/
>
> Got Gmail? I have 100 invites.
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the
subject of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by
CFXHosting (www.cfxhosting.com).
>
> CFCDev is supported by New Atlanta, makers of BlueDragon
> http://www.newatlanta.com/products/bluedragon/index.cfm
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
>
>
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the
subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by
CFXHosting (www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
-----------------------------------------------------------------------
http://www.switch-box.org/CFSQLTool/Download/
Switch_box MediaFirm, Inc.
www.Switch-box.org Loveland, CO USA
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]