Connecting withOUT Data Source

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

  1. #1

    Default Connecting withOUT Data Source

    Is anyone aware of a way to provide JDBC connection strings to CF at runtime?
    We have an application that connects to a number of databases depending on the
    user logging in. Basically each user connects to their own database. Each time
    I bring a new user onboard I have to create a data source in the admin. I want
    to avoid this.

    The app is a mix of CF and ASP.NET and on the .NET side I simply put the new
    connection string in a database and the .NET retrieves it and connects using
    it, I want to create the same functionality on the CF side.

    Am I forced to use the data sources defined in the admin?

    Thanks,
    -Walden

    Walden Guest

  2. Similar Questions and Discussions

    1. Problem connecting to Data Source
      Hi, I seem to be having a problem connecting to a data source, now that I have changed the cfform to flash format. This is the error I am...
    2. connecting to data source
      After accessing the Coldfusion administrator \ Data sources. Eventhough many datasources were set up, none of them could be accessed. The following...
    3. Error Connecting SQL 2000 Data Source to CF
      I am trying to setup SQL 2000 in conjunction with CF MX 7. CF is serving pages fine and I created a new account in SQL and that is working fine. I...
    4. Problem connecting to ODBC data source from CFAdministrator
      I've set up the data source called vs28718_1 for Windows Authentication but I get the following error in CF Administrator when submitting the data...
    5. Problem connecting site to data source
      :light; Thanks for guiding. I had the same problem and just found what I missed it. Thanks again
  3. #2

    Default Re: Connecting withOUT Data Source

    If you are using CF MX 7, you have to use the Admin APIs. Below is an example
    of how to create a data source in CF without using the Administration Console:

    <cfscript>
    // Login is always required. This example uses a single line of code.
    createObject("component","cfide.adminapi.administr ator").login("admin");

    // Instantiate the data source object.
    myObj = createObject("component","cfide.adminapi.datasourc e");

    // Required arguments for a data source.
    stDSN = structNew();
    stDSN.driver = "MSSQLServer";
    stDSN.name="northwind_MSSQL";
    stDSN.host = "DARRELL";
    stDSN.port = "1433";
    stDSN.database = "northwind";
    stDSN.username = "sa";

    // Optional and advanced arguments.
    stDSN.login_timeout = "29";
    stDSN.timeout = "23";
    stDSN.interval = 6;
    stDSN.buffer = "64000";
    stDSN.blob_buffer = "64000";
    stDSN.setStringParameterAsUnicode = "false";
    stDSN.description = "Northwind SQL Server";
    stDSN.pooling = true;
    stDSN.maxpooledstatements = 999;
    stDSN.enableMaxConnections = "true";
    stDSN.maxConnections = "299";
    stDSN.enable_clob = true;
    stDSN.enable_blob = true;
    stDSN.disable = false;
    stDSN.storedProc = true;
    stDSN.alter = false;
    stDSN.grant = true;
    stDSN.select = true;
    stDSN.update = true;
    stDSN.create = true;
    stDSN.delete = true;
    stDSN.drop = false;
    stDSN.revoke = false;

    //Create a DSN.
    myObj.setMSSQL(argumentCollection=stDSN);
    </cfscript>

    for more info, check out:

    [url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/[/url]
    wwhelp.htm?context=ColdFusion_Documentation&file=0 0001734.htm


    CFGoneWild Guest

  4. #3

    Default Re: Connecting withOUT Data Source

    Thanks for the info -- I'm not on 7, but I suppose we could go there. Still,
    the API allows us to create data sources w/out needing the admin console, but
    I'd still rather simply supply the connection string at runtime. I've got a
    centralized database that describes a "client" and what database & server they
    are on. I'd rather have to just change that one DB and have all the code see
    the change. Works great in .NET where I don't need a data source defined, it's
    more of a pain in java (CF) where I do need the data source defined.

    Still, at least the API removes the need to visit the admin screen on the
    servers.

    Thanks,
    -Walden

    Walden Guest

  5. #4

    Default Re: Connecting withOUT Data Source

    DSN-less connections lived and died with CF5's CFQUERY tag. You're pretty much stuck with the ODBC-style connection in MX.
    philh Guest

  6. #5

    Default Re: Connecting withOUT Data Source

    That's what I was afraid of. In this world of "software as a service" and application service providers, it's really a shame to have to deal with such a limitation. But oh well.. Thanks.

    -Walden
    Walden 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