Programmatically disable DSN

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

  1. #1

    Default Programmatically disable DSN

    Hi all,

    I have a CF MX 6.1 app that accesses an AS/400 DB2 database, but I need to
    make sure ColdFusion disconnects from DB2 at a particular time so a backup can
    proceed. I found the following code that is supposed to do this:

    <cflock name="serviceFactory" type="exclusive" timeout="10">
    <cfscript>
    factory = CreateObject("java", "coldfusion.server.ServiceFactory");
    ds_service = factory.datasourceservice;
    dsources = ds_service.datasources;
    dsources["your_dsn"]["disable"] = "Yes/No";
    ds_service.restart();
    </cfscript>
    </cflock>

    However, when I test this against a MySQL DSN (after plugging in my DSN name
    and using the "Yes" option) and monitor the MySQL connections, it does not
    appear that it's breaking the CF-maintained connection.

    Anyone have any ideas?

    Thanks,
    Russ

    rchinoy Guest

  2. Similar Questions and Discussions

    1. programmatically creating a cf5 dsn
      Hello, I was curious if there was a way to programmatically create a coldfusion dsn for a ms sql 2000 database using coldfusion 5.0 code? i have...
    2. programmatically add DSN
      How can I access a db without first registering in CF Administrator datasources? Can I programmatically (like asp) create a datasource in the .cfm...
    3. How to disable copy/past (selectable='disable') fromTextArea
      How to disable copy/past and text selection ability from TextArea? <mx:Text has a nice selectable='false' propertie, but TextAre hasn't. Very,...
    4. Saving A PDF as a PNG Programmatically
      I need to save PDFs as BMP files, scaled down in size. The closest thing I found was PDFtoIMG, but it crops the right edge and the bottom edge. I...
    5. Disable impersonation programmatically?
      Hi, I have an issue with Indexing service and impersonation, namely that Indexing service do not work properly with <identity...
  3. #2

    Default Re: Programmatically disable DSN

    Are you not able to do this at the database end? The way we deal with this is:
    1. make the database unavailable when required using database methods.
    2. In Cold Fusion, test the database for availability before attempting to
    use it. Using Oracle as an example
    <cftry>
    <cfquery>
    select sysdate from dual
    </cfquery>
    <cfset ok = true>
    <cfcatch>
    <cfset ok = false>
    </cftry>
    <cfif ok>
    run your page
    <cfelse>
    explain why not
    </cfif>

    Dan Bracuk 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