Here’s a truncated Application.cfc. When I run this, the ‘first_dsn’
defined directly seems to work fine, however ‘second_dsn’ complains that it
is not defined.
return true;
}
public void function setupSecondDatasource() {
this.datasources[ 'second_dsn' ] = {
/* valid datasource definition */
};
}
}
If instead I do not define ‘first_dsn’ then ‘second_dsn’ works fine (see
below). It is as if by defining a datasource in the component body it
prevents datasources being defined later. I have seen similar by defining
datasources within the Lucee admin + then being unable to define any
OnRequestStart() also.
component {
this.defaultDatasource = 'second_dsn';
public boolean function onRequestStart(
required string targetPage
) {
setupSecondDatasource();
QueryExecute( sql=" ... " ); // Works fine
return true;
}
public void function setupSecondDatasource() {
this.datasources[ 'second_dsn' ] = {
/* valid datasource definition */
};
}
}
Does anyone have any ideas as to what either I have done wrong, or how I
can work around this? I need ‘first_dsn’ pretty soon in the boot process
due to it being used as a session store however ‘second_dsn’ is variable
based on hostname and so far creating this at OnRequestStart has proved
reliable.
}On Wednesday, 8 July 2015 09:29:47 UTC+1, Simon Hooker wrote:
Here’s a truncated Application.cfc. When I run this, the ‘first_dsn’
defined directly seems to work fine, however ‘second_dsn’ complains that it
is not defined.
return true;
}
public void function setupSecondDatasource() {
this.datasources[ 'second_dsn' ] = {
/* valid datasource definition */
};
}
}
If instead I do not define ‘first_dsn’ then ‘second_dsn’ works fine (see
below). It is as if by defining a datasource in the component body it
prevents datasources being defined later. I have seen similar by defining
datasources within the Lucee admin + then being unable to define any
OnRequestStart() also.
component {
this.defaultDatasource = 'second_dsn';
public boolean function onRequestStart(
required string targetPage
) {
setupSecondDatasource();
QueryExecute( sql=" ... " ); // Works fine
return true;
}
public void function setupSecondDatasource() {
this.datasources[ 'second_dsn' ] = {
/* valid datasource definition */
};
}
}
Does anyone have any ideas as to what either I have done wrong, or how I
can work around this? I need ‘first_dsn’ pretty soon in the boot process
due to it being used as a session store however ‘second_dsn’ is variable
based on hostname and so far creating this at OnRequestStart has proved
reliable.
right. the issue is that the datasources – like other settings of the
nature of this.someSetting in Application.cfc – must be in the body
(pseudo constructor) of the Application.cfc and can not be inside functions.
On Wednesday, 8 July 2015 09:29:47 UTC+1, Simon Hooker wrote:
Here's a truncated Application.cfc. When I run this, the
'first_dsn' defined directly seems to work fine, however
'second_dsn' complains that it is not defined.
|
component {
this.datasources['first_dsn']={
/* valid datasource definition */
};
this.sessionCluster =true;
this.sessionStorage ='first_dsn';
this.defaultDatasource ='second_dsn';
publicbooleanfunctiononRequestStart(
required stringtargetPage
){
setupSecondDatasource();
QueryExecute(sql=" ... "); // Errors because second_dsn
(default ) is not defined
returntrue;
}
publicvoidfunctionsetupSecondDatasource(){
this.datasources['second_dsn']={
/* valid datasource definition */
};
}
}
|
If instead I do not define 'first_dsn' then 'second_dsn' works
fine (see below). It is as if by defining a datasource in the
component body it prevents datasources being defined later. I
have seen similar by defining datasources within the Lucee admin +
then being unable to define any OnRequestStart() also.
|
component {
this.defaultDatasource ='second_dsn';
publicbooleanfunctiononRequestStart(
required stringtargetPage
){
setupSecondDatasource();
QueryExecute(sql=" ... "); // Works fine
returntrue;
}
publicvoidfunctionsetupSecondDatasource(){
this.datasources['second_dsn']={
/* valid datasource definition */
};
}
}
|
Does anyone have any ideas as to what either I have done wrong, or
how I can work around this? I need 'first_dsn' pretty soon in
the boot process due to it being used as a session store however
'second_dsn' is variable based on hostname and so far creating
this at OnRequestStart has proved reliable.