• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

application.cfc error with datasource

Contributor ,
May 20, 2016 May 20, 2016

Copy link to clipboard

Copied

I am getting an error with my application.cfc file for my database. I am using coldfusion 10 on a windows machine. This application file works on cf 9 and 8 and I do not know what the problem is now. I get the error:

"

Error Occurred While Processing Request

Element DATASOURCE is undefined in APPLICATION."


This is my code and I have tried too make it work 2 ways:

<cfcomponent>

<cfset This.name = "My App">

<cfset This.datasource ="1093644">

<cfset This.clientmanagement="True">

<cfset This.loginstorage="Session">

<cfset This.sessionmanagement="True">

<cfset This.sessiontimeout="#createtimespan(0,0,10,0)#">

<cfset This.applicationtimeout="#createtimespan(5,0,0,0)#">

<cfset THIS.setClientCookies = "1">

<cfset THIS.setDomainCookies = "1">

<cfset THIS.scriptProtect = "All">

<cfsetting showdebugoutput="yes" />

<cffunction name="onApplicationStart" output="false" access="public">

<cfset APPLICATION.EncryptionKey = "S3xy8run3tt3s" />

<cfscript>

  APPLICATION = structNew();

  //site-wide datasource(s)

  APPLICATION.datasource = "1093644";

  strArgs = structNew(); // flush strArgs

  strArgs.datasource = APPLICATION.datasource;

    return true;

  </cfscript>

</cffunction>


I am trying to call it up with my queries like this:

<cfquery name="myQuery" datasource="#APPLICATION.datasource#" dbtype="ODBC">

This is a stupid error and I can't figure it out. I also tried doing this to put the db into the component:

<cfscript>

THIS.name = "myApp";

THIS.datasource = "1093644";

THIS.sessionManagement=true;

THIS.clientManagement=true;

THIS.applicationTimeout = createTimeSpan(0,0,20,0);

THIS.loginStorage = "session";

THIS.sessionTimeout = createTimeSpan(0,0,20,0);

if( isdefined('session') AND structkeyexists(session, 'times_logged_on')

AND session.times_logged_on gte 3 ) THIS.sessiontimeout =

createtimespan(0,0,10,0);

THIS.setClientCookies = 1;

THIS.setDomainCookies = 1;

THIS.scriptProtect = "All";

THIS.secureJSON = false;

THIS.secureJSONPrefix = "";

THIS.mappings = createMappings(pathPrefix="/");

</cfscript>

This app is on a mysql db. If I just use a query with the db name in it, it works. It's not liking my application.cfc code.

Can anyone help me figure out what the issue is? This is also on a shared hosting server.
Thank you.

TOPICS
Database access

Views

768

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 21, 2016 May 21, 2016

APPLICATION = structNew();

That line is incorrect, so delete it. APPLICATION is already defined, as it is an in-built structure in ColdFusion.

Votes

Translate

Translate
Community Expert ,
May 21, 2016 May 21, 2016

Copy link to clipboard

Copied

LATEST

APPLICATION = structNew();

That line is incorrect, so delete it. APPLICATION is already defined, as it is an in-built structure in ColdFusion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation