|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Quote:
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! |
|
#4
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Query DBs not defined in admin? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|