ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old June 17th, 2004, 11:08 AM
Gnosis Gnosis is offline
Sellout
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 205 Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 10 h 14 m 58 sec
Reputation Power: 6
Query DBs not defined in admin?

I'm a relative newb to CF (prefer PHP), but I have to write an app....

I understand the way the whole datasource thing works, and I have no problem setting up datasources in the admin and using them. However, I'm developing an app that's going to go on a client's server and I don't control the admin. I'm not even sure what db server we're going to end up using.

So the question is, how can I query a db that's not set up as a "datasource"? If I know the server address, username, pass, and db to use, I should be able to query any db on the planet, no? But I can't figure out how to write the code to do it.

Any help is mucho appreciado.

-G

Reply With Quote
  #2  
Old June 17th, 2004, 12:08 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
CFMX (assuming you are on MX) does not allow ad-hoc database connections. You'll either have to set up the datasource in the administrator, or attempt to create a connection using the underlying Java API classes.

There is one other way, you can invoke the underlying ColdFusion Java classes that handle creation and manipulation of datasources. But this is "unsupported" and could break in future versions of CF if they change the underlying behavior.

One way to approach this is to create variables for datasource name, password, etc. that you set once, perhaps in the Application.cfm file. Then set these variables to the proper values for your local machine and use the variables in all of your cfquery tags. Later, when you transfer the application to another server, all you need to do is change the variable assignments (if necessary). This way the production server can use whatever RDBMS, datasource name, password, etc. that it needs to, and you can easily switch over to using those settings.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Last edited by kiteless : June 17th, 2004 at 12:11 PM.

Reply With Quote
  #3  
Old June 17th, 2004, 12:31 PM
Gnosis Gnosis is offline
Sellout
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 205 Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level)Gnosis User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 10 h 14 m 58 sec
Reputation Power: 6
Quote:
Originally Posted by kiteless
One way to approach this is to create variables for datasource name, password, etc. that you set once, perhaps in the Application.cfm file. Then set these variables to the proper values for your local machine and use the variables in all of your cfquery tags...


Yep, that's exactly what I'm doing for now. Unfortunately, my boss wants to see a sample of the app on the production server even though the db decision hasn't been made yet! So I was hoping to connect to my dev db from the production server without a formal DSN.

Thanks for the clarification. It's good to know that I just can't do that in CFMX. Why not is another question! Oh well. Sounds like it's a case of "can't get there from here". If da boss wants to see the app, he'll have to come look at it on my machine!

Reply With Quote
  #4  
Old June 17th, 2004, 12:45 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Oh, it IS possible by calling the Java classes, but that would be much messier than cfquery.

This might help as well? http://www.macromedia.com/support/c...ic_dsn_cfmx.htm

And this shows nicely how to use CFMX's underlying Java-based classes to manipulate datasources:

http://spike.oli.tudelft.nl/jochemd/index.cfm?PageID=12

Last edited by kiteless : June 17th, 2004 at 12:48 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Query DBs not defined in admin?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway