Posted by christopher on October 21st, 2007
I’ve recently accomplished having my application rebuild its datasource when the application is created in BlueDragon 7. I’m not sure how supported this is going to be by New Atlanta, but a neat little hack anyways. First let me state that while this seems like an odd thing to do, the purpose of this was to allow users of my application to modify a configuration file to setup their datasource instead of have them muck around in the BD7 Admin.
For ease of display, I’ve removed the code where I read the parameters from the file. Also, I only do this when the application starts - you could embed this into a configuration or install page instead.
All code below uses <--- comment ---> which excludes the exclamation point. This is because this blog software seems to consider them as actual comments to be ignored even when in code blocks.
<--- Connect the the BlueDragon Admin --->
<cfset bdadmin = CreateObject( "component","bluedragon.admin")>
<--- Initialize with BD Admin Password --->
<cfset variables.tmp = bdadmin.init('password')>
<--- Remove Existing Datasource --->
<cftry>
<cfset variables.tmp = bdadmin.removedsn(variables.dsname)>
<cfcatch type="any">
</cfcatch>
</cftry>
<-- Create New Datasource -->
<cfset variables.tmp = bdadmin.adddsn(
'sqlserver'
,lcase(variables.dsname)
,variables.dbname
,variables.description
,variables.dbsrvr
,variables.dbport
,variables.dbuser
,variables.dbpass
,'120'
,'3'
,'120'
,''
,''
,'true'
,'true'
,'true'
,'true'
,'true'
,''
,''
,''
)>
I probably spent an hour before I was able to come up with the first parameter (sqlserver). I looked at the BD XML Configuration file, looked at JTurbo sites, guessed at them, but they all failed saying that they weren’t valid. I finally got sqlserver from a complete unrelated page that was listing various database types and realized I hadn’t tried that variation yet. Other values that seemed to work were “mysql” and “postgresql”. While I didn’t test it, I assume the value “oracle” would work as well.
Now, what are all those parameters that I’m not using variables for? You can expose them as follows:
<--- Connect the the BlueDragon Admin --->
<cfset bdadmin = CreateObject( "component","bluedragon.admin")>
<--- Initialize with BD Admin Password --->
<cfset variables.tmp = bdadmin.init('password')>
<--- Dump It! --->
<cfdump var="#bdadmin#">
This includes a list of everything you can call using the BDADMIN component. Scroll down to addDSN to see what parameters can be manipulated. Good luck!
Bookmark to:
Posted in Code Snippets, Tips and Tricks, BlueDragon | No Comments »
Posted by christopher on October 21st, 2007
Posted in ColdFusionUsers | No Comments »
Posted by christopher on September 12th, 2007
In the last few weeks I’ve been toying a bit with AJAX in some simple demo ColdFusion apps - pretty much just testing the waters. For anyone who, like me, has been slow to adopt AJAX, it’s time to jump in. I’ll try and post some of my little samples for anyone who might be thinking of trying it out sometime soon. In the mean time, here was my experience…
I decided to try the two most popular (in the usergroups and forums anyway) AJAX components out there: CFAjax and AjaxCFC. I read up a bit on both of them and there’s no one out there that’s really dismissing either - most people agreeing that they each have their pros and cons.
For no good reason whatsoever, I tried CFAjax first. It was very easy to install and the setup instructions were very straightforward. I got it all set, ran a test to make sure it was working, and life was good. I spent about an hour trying to get my own AJAX application to work on top of it, and I honestly couldn’t. Maybe I had missed a step, or maybe I was overlooking the obvious somewhere, but it just wasn’t happening. I decided to move on and try the next one, coming back to this if I needed to later.
AjaxCFC was a whole different story. Setup was a breeze (not that CFAjax wasn’t, they both were very easy), and I immediately got a new test application working - first try! After getting a pretty basic function working that would just accept text I entered, manipulate it in some way and pipe it back out, I wanted to test out some queries. This proved just a smidge more difficult. At no fault of AjaxCFC, I couldn’t figure out how to manipulate the query data once it was returned from the server. After reading up (it’s been a while!) on my javascript, I got it going.
For anyone who runs into this as their first snag, you reference your query as follows:
returnvar.column_name[row_number]
For example:
Now obviously you can plop your variables in there and have a dynamic AJAX application running in no time! Kudos Rob Gonda for AjaxCFC
Bookmark to:
Posted in ColdFusion, AJAX | No Comments »
Posted by christopher on September 10th, 2007
Posted in IIS Web Server | No Comments »
Posted by christopher on January 18th, 2007
Posted in ColdFusion | No Comments »
Posted by christopher on November 5th, 2006
I see questions posted in various places regarding ColdFusion applications trying to access remote network shares. The most common problem in doing this is getting denied access — and the most common troubleshooting step is logging into the server and accessing the share. They can often access the share just fine. Unfortunately, this thought process is flawed. The reason is because ColdFusion is not running as any user who is logged in, it is running using a service account (such as one you’ve created, or LocalSystem). This account probably doesn’t have access to the remote share.
To check which user’s context that ColdFusion is running under, follow these steps:
- Right Click My Computer, then select Manage.
- If you’re not on the server, right click Computer Management, click “Connect to Another Computer” and pick your CF Server.
- Expand Services & Applications.
- Click the Services Item.
- Right Click the ColdFusion Application Server service, select properties.
- Select the Log On Tab.
If “Local System Account” is selected, you can be 99% certain that ColdFusion will have no access to any network shares at all. Otherwise, you’ll now know exactly which account is running ColdFusion. This is the account that you’ll want to make sure has permission to access the share you’re looking for. When possible, you should login to a workstation with the account to test security permissions. If the account is granted access to a share, it’s often necessary to restart the service before it will take effect.
Bookmark to:
Posted in Tips and Tricks | No Comments »
Posted by christopher on October 25th, 2006
As part of a recent a ColdFusion project, I needed to query an Oracle database and accept anywhere from 0 to 30k-40k records, then export into a CSV. It didn’t seem like too difficult of a problem at first. I used Toad to build the perfect query. Once optimized to pull down the max amount of records in the least amount of time, I copied to ColdFusion, built my front end, tested, and released. How’d I do it? Seemed simple — I setup a variable with a CSV header row, and then appended the variable record by record with the new data, and at the end CFFILE’d it all into a temp file which I then presented to the user.
Almost immediately after releasing the page into the application, I started having memory issues on my ColdFusion box. I’d watch the task list and just see JRUN rise to unreasonable percentages, and every so often - just hang. Killing the process and restarting the service was the only solution. It was obvious that the report was the problem, and it needed to be fixed ASAP.
The solution is something that should have come to mind immediately. Trying to store upwards of 30k records in a variable probably was not the smartest solution I’ve come up with, and probably was maxing out those few gigs of RAM that I have allocated to that box. My solution? Instead of writing the data out to a temp file when I had collected it all to begin with, I change the code so that it would export after I had a complete record, and then clearing the variable. Not only did this alleviate all of the JRUN issues I was having, but also sped up the report significantly.
My lesson learned? Just because you can do something, doesn’t mean it’s the best way; take time to think. Unfortunately deadlines will often conflict with your ability to reason with your code
Bookmark to:
Posted in Tips and Tricks | No Comments »
will not give you cold like some other languages. You can use a
. Then a
purpose. Its always good to work on the informative numbers
that will give you an edge in the network world.