Ask a Question related to Coldfusion Database Access, Design and Development.
-
PhilRV6 #1
Data Sources
Can anyone tell me how to get a list of Data Sources from CF server using cfml?
Thanks: Phil
PhilRV6 Guest
-
How to add security to data sources from SQL 2000
How to add security to data sources from SQL 2000 I have been doing ColdFusion programming for over 5 years and now I hired an assistant for... -
backup data sources
Is it possible to backup data sources from one server to another? I need to move data sources from Coldfusion MX to Coldfusion MX 7 server. Thanks... -
Restoring data sources in CF 5.0
Hello guys, Could you please suggest a way to backup data sources for sybase, oracle and db2 from one UNIX server (Solaris) to another Solaris... -
The IListSource does not contain any data sources. <-- ?
Hi When I execute an SQL steatement, I retreive a Dataset. For some queries which does not return any data, If I assign it to the... -
how to access data from 2 different sources?
I need to use data from multiple tables that are located in 2 different databases. Most of the tables are in SQL Server 2000 but 1 one the tables I... -
qateef #2
Re: Data Sources
<cfscript>
application.ServiceFactory =
CreateObject("java","coldfusion.server.serviceFact ory");
DSN =
listSort(structKeyList(application.ServiceFactory. DatasourceService.getDatasourc
es()),"textnocase","asc"):
</cfscript>
now you need to query the list and you can do that by doing the following:
<select name="myDSN">
<option value=""></option>
<cfloop list="#dsn#" index="i">
<option value="#i#>#i#</option>
</cfloop>
</select>
Good luck
Mamdoh Al-Habeeb
qateef Guest
-
PhilRV6 #3
Re: Data Sources
Thanks for responding. I gave it a try and got this error message:
Error Occurred While Processing Request
Object Instantiation Exception.
Class not found: coldfusion.server.serviceFactory
I'm thinking that I need a Java class called serviceFactory? If so, where can
I find it? Or, what could I be doing wrong?
Thanks again for your help: Phil
PhilRV6 Guest
-
boughtonp #4
Re: Data Sources
Yes, it's Java - part of the CFMX core class thingies. (and an 'undocumented
feature', so it might not be in future versions; use at your own risk, etc)
Here's a useful blog entry about it: [url]http://www.petefreitag.com/item/152.cfm[/url]
If you're using CF5 then obviously it wont work. Not sure if there are any
alternative methods.
boughtonp Guest
-
qateef #5
Re: Data Sources
Dear PhilRV6,
I am sorry, I should mentioned that the code I provided you with ealier is for CFMX and what Mr. Peter said is true that this code will not work for CF5.
qateef Guest
-
PhilRV6 #6
Re: Data Sources
I am running 7. Should it work here, or do I need a different class?
Thanks Much: Phil
PhilRV6 Guest
-
boughtonp #7
Re: Data Sources
Looks like the name is case-sensitive; you need a capital S on ServiceFactory.
boughtonp Guest
-
PhilRV6 #8
Re: Data Sources
It's working great. Thank you both very much for your help.
Sincerely: Phil Spingola:D
PhilRV6 Guest
-
PhilRV6 #9
Re: Data Sources
After using the solution that was provided, I realised that it did not return
the Driver type (Access, Oracle, SQL 2000). Does anyone know how to get this
call to do this. I have not been able to find doc on it.
Thanks for any help you can give!
Sincerely: Phil
<cfscript>
application.ServiceFactory =
CreateObject("java","coldfusion.server.serviceFact ory");
DSN =
listSort(structKeyList(application.ServiceFactory. DatasourceService.getDatasourc
es()),"textnocase","asc"):
</cfscript>
PhilRV6 Guest
-
ksmith #10
Re: Data Sources
Hi Phil,
Get adventurous and explore the code you have been given. Attached is code
that gives you a table of dsn names and drivers. Below it I dump the structure
returned by the getDatasources method.
<CFOBJECT TYPE="JAVA" ACTION="Create" NAME="factory"
CLASS="coldfusion.server.ServiceFactory">
<cfscript>
DSN =
listSort(structKeyList(factory.DatasourceService.g etDatasources()),"textnocase",
"asc");
</cfscript>
<table border="1" bordercolor="#000000">
<tr><th>DSNname</th><th>Driver</th></tr>
<cfloop index="key" list="#DSN#">
<cfoutput><tr><td>#key#</td><td>#dsnCollection[key].driver#</td></tr></cfoutput</cfloop>>
</table>
<br><br>
<cfdump var=#dsnCollection#>
ksmith Guest



Reply With Quote

