New to ColdBox

42 views
Skip to first unread message

Nkonye Oyewusi

unread,
Sep 5, 2016, 1:03:14 PM9/5/16
to ColdBox Platform
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.

Ancient Programmer

unread,
Sep 5, 2016, 11:25:24 PM9/5/16
to ColdBox Platform
In /config/ColdBox.cfc - configure(), add the following:

datasource = {
coldbox_test   = {name="your_dsn"}
};

br...@bradwood.com

unread,
Sep 5, 2016, 11:40:08 PM9/5/16
to col...@googlegroups.com
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: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
Subject: [coldbox:25927] New to ColdBox
From: "Nkonye Oyewusi" <tall...@gmail.com>
Date: 9/5/16 10:44 am
To: "ColdBox Platform" <col...@googlegroups.com>

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
 */

   
ContactDAOfunction init(){
       
returnthis;
   
}

    query
function getAll(){

   
var q =newQuery(datasource="#dsn#",sql="SELECT * FROM contacts");

   
return q.execute().getResult();
 
}

  query
function getContact(required contactID){

   
var q =newQuery(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.

 

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/8a0aa143-4fe2-429f-9bab-3e9943cef98c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages