New to ColdBox

Hello,

I’m trying to create a simple CRUD app in ColdBox.

I have in my handler Contacts.cfc with all the methods.

I have in my models Contacts.cfc, ContactsService.cfc and ContactsDAO.cfc.

The problem is that in ContactsDAO.cfc, ColdBox does not recognise the DSN, even though it has been created in myCFAdministrator. I get the following erre:Builder.DSLDependencyNotFoundException

The code is as follows:

`
Enter code here./**

  • I am a new Model Object
    */
    component singleton accessors=“true”{

// Dependency Injection
property name=“dsn” inject=“coldbox:datasource:coldbox_test”;

/**

  • Constructor
    */
    ContactDAO function init() {
    return this;
    }

query function getAll(){
var q = new Query(datasource="#dsn#",sql=“SELECT * FROM contacts”);
return q.execute().getResult();
}

query function getContact(required contactID){
var q = new Query(datasource="#dsn#",sql=“SELECT * FROM contacts WHERE contact_id = :contactID”);
q.addParam(name=“contactID”,value=arguments.contactID,cfsqltype=“cf_sql_numeric”);
return q.execute().getResult();
}

/… ALL OTHER METHODS HERE FOR CRUD …/

}…
`

Any ideas as to how to fix this?

Thanks.

In /config/ColdBox.cfc - configure(), add the following:

`

datasource = {
coldbox_test = {name=“your_dsn”}
};

`

Have you set up the data source in your ColdBox config file? You’re asking Wirebox to inject a specific data source setting with the name “coldbox_test”, which may or may not coincide with the name of the actual data source in your CF administrator.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com