|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Adding DSN with ColdFusion Factory
All,Jake 05/23/04 12:14 A >I'm looking for a way to add datasources via code, using the cf.Factory.mpwoodward 05/23/04 08:28 A Jake. wrote:Jochem van Dieten 05/23/04 11:19 A Jake,Andrew Scott 05/23/04 10:51 P All, I know that this has been much talked about, but after an hour of searching I'm still without real answers. I'm looking for a way to add datasources via code, using the cf.Factory. I came across a great CFC for adding mappings (www.cfczone.org <http://www.cfczone.org/> ), but I can't seem to find something similar for datasources. I've found a few discussions/pages about the theory of how you would do this, but nothing will actual code. Can someone help me out? Thanks! Jake -- BlogFusion - www.countersinkdg.com <http://www.countersinkdg.com/> Getting Started with LEGO Trains - www.bricksonthebrain.com/trains -- My Blog - <http://www.smackmybooty.com/> www.smackmybooty.com Building Instructions Portal - <http://www.bricksonthebrain.com> www.bricksonthebrain.com LEGO Photoblog - www.bricksonthebrain.com/photoblog Getting Started with LEGO Trains - www.bricksonthebrain.com/trains >I'm looking for a way to add datasources via code, using the cf.Factory. >I came across a great CFC for adding mappings (www.cfczone.org ><http://www.cfczone.org/> ), but I can't seem to find something similar >for datasources. I've found a few discussions/pages about the theory of >how you would do this, but nothing will actual code. http://spike.oli.tudelft.nl/jochemd/index.cfm?PageID=12 Thanks for that link. I played around with it last night, and got it to added the datasource. But there are still several key pieces missing (like how to do you find the name of an existing datasource in order to model it, how do you check to ensure there aren’t any existing DSNs with that same name, how do you associate the actual DB with the DSN you created, etc.) I was hoping that there might be a CFC or something out there like the mappings.cfc from CFCZone.org that handles the entire process. (With something like this, I don’t want to do it wrong!) Any other pointers? Jake ----- Excess quoted text cut - see Original Post for more ----- Jake. wrote: <cflock name="serviceFactory" type="exclusive" timeout="10"> <cfscript> factory = CreateObject("java", "coldfusion.server.ServiceFactory"); ds_service = factory.datasourceservice; d_sources = ds_service.datasources; </cfscript> </cflock> > like how to do you find the name of an existing datasource in order to model it To list all the datasources: <cfoutput>#StructKeyList(d_sources)#</cfoutput> > how do you check to ensure there aren稚 any existing DSNs with that same name Presuming your new datasource is named "foobar": <cfif StructKeyExists(d_sources, "foobar")> <cfthrow message="A datasource with that name already exists."> </cfif> > how do you associate the actual DB with the DSN you created That depends on the driver, just create one using the administrator and then have a good look at the structure that is created. For instance, for PostgreSQL it is controlled exclusively by the URL, while for Access with Unicode you need to set the URL, the urlmap.databasefile and the urlmap.connectionprops.databasefile. Jochem Jake, I have a CFC that will do the trick for you, it is shareware and I a mhappy to pass this on as long as copyright is remain to the author. The cfc will allow you to create, delete and verify a data source for MsAccess and Ms SQL Server at the moment. If this fits your needs let me know. Regards Andrew Scott Technical Consultant NuSphere Pty Ltd Level 2/33 Bank Street South Melbourne, Victoria, 3205 Phone: 03 9686 0485 - Fax: 03 9699 7976
|
July 31, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||