Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Data Sources

    Can anyone tell me how to get a list of Data Sources from CF server using cfml?

    Thanks: Phil

    PhilRV6 Guest

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default Re: Data Sources

    I am running 7. Should it work here, or do I need a different class?

    Thanks Much: Phil
    PhilRV6 Guest

  8. #7

    Default Re: Data Sources

    Looks like the name is case-sensitive; you need a capital S on ServiceFactory.
    boughtonp Guest

  9. #8

    Default Re: Data Sources

    It's working great. Thank you both very much for your help.

    Sincerely: Phil Spingola:D
    PhilRV6 Guest

  10. #9

    Default 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

  11. #10

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139