Skip to main content
gregh41185636
Participant
August 30, 2017
Answered

CF2016 CLI - Datasource could not be found

  • August 30, 2017
  • 2 replies
  • 1717 views

I have written a basic page as a Proof of Concept that runs a basic query from a single table.  If I run the page via web browser the page displays the resultset form query but from CLI it fails with the error about the datasource not being found.

Do I have to configure something to enable the CLI to be able to read the datasources?

If I cannot figure this out, then I will have to switch languages to provide a CLI option for getting data into my system.

Thank you for any information you can provide.

Greg Howard

This topic has been closed for replies.
Correct answer haxtbh

The CLI spins up a mini server when its run, it has no concept of the datasources you require so they need to be setup when the CLI is run.

You need to set up an Application.cfc with the datasources being created here. Then used later in your code.

Command Line Interface in ColdFusion 2016 | Adobe Developer Connection

See examples of setting up datasources here - ColdFusion Help | Application variables

2 replies

haxtbhCorrect answer
Inspiring
August 30, 2017

The CLI spins up a mini server when its run, it has no concept of the datasources you require so they need to be setup when the CLI is run.

You need to set up an Application.cfc with the datasources being created here. Then used later in your code.

Command Line Interface in ColdFusion 2016 | Adobe Developer Connection

See examples of setting up datasources here - ColdFusion Help | Application variables

gregh41185636
Participant
August 30, 2017

Thank you so much!  Defining an application.cfc with this.datasources fixed my error.  In case anyone else needs help with this, I placed an application.cfc in the same directory as my .cfm page and a sample of the application.cfc are below.  I copied the URL string straight out of my neo-datasources.xml of my CF server for the needed datasource.

component {

this.datasources = {

MyDSN = {

driver = "MSSQLServer"

, username = "MyUserName"

, password = "ValidPassword"

, url = "jdbc:macromedia:sqlserver://172.1.1.1:1433;databaseName=MyDSN;SelectMethod=direct;sendStringParametersAsUnicode=false;queryTimeout=0;MaxPooledStatements=100;jdbcbehavior=0"

}

};

}

WolfShade
Legend
August 30, 2017

I know nothing of CLI in CF, however a quick Google search did come up with a few things.

After the install, did you run wsconfig?

V/r,

^ _ ^

gregh41185636
Participant
August 30, 2017

Thanks for the suggestion.  I ran wsconfig when we performed the install, but wsconfig is what configures ColdFusion to run with your preferred web server (hence the ws in wsconfig).  Nothing in the wsconfig mentioned Command Line Interface.