Thursday, July 2, 2009

DSN-Less Database Connection to MySQL in Coldfusion

Have not tried this myself yet, but wanted to drop it here so we can play with it in the future.

A DSN-less connection is made completely through the code, without the need for configuring anything within the ColdFusion Administrator. All of the information for the connection is specified within the code. This includes the driver, servername, databasename, username and password.


To make a DSN-less connection to a MySQL database, the following code snippet can be used:



<cfscript>

classLoader = createObject("java", "java.lang.Class");
classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dm = createObject("java","java.sql.DriverManager");

con = dm.getConnection("jdbc:odbc:DRIVER={MySQL ODBC 3.51 Driver}; SERVER=server; PORT=3306;
DATABASE=database; USER=username; PASSWORD=password;OPTION=3;");


st = con.createStatement();
rs = st.ExecuteQuery("Select * FROM table");
q = createObject("java", "coldfusion.sql.QueryTable").init(rs);

//the query is stored in the variable q


</cfscript>

Wednesday, July 1, 2009

Image Expired: Please Refresh The Page to View This Image

We've run into this problem before and so I've stolen the solution from the cfchart blogspot blog site:


Problem

The following message is shown instead of the graphs:
"Image Expired
Please refresh the page
To view the image"


Lot of people have faced this problem, the reason is the timeout in the caching engine of the Coldfusion keeps the charts for any request only for a default value of 5 seconds.
We missed providing an interface to change this value in the CF Admin, but you can still change this value by:

1. Stop the CF server.
2. Open <cf install path>\lib\webcharts3d.xml
3. You can increase the timeout for keeping the graphs in the cache by editing the minTimeout and maxTimeout attributes:

<?xml version="1.0" encoding="UTF-8"?>
<server image="PNG" cache="Memory" minTimeout="5000" maxTimeout="30000"....

change this to whatever values you want.(Values of minTimeout and maxTimeout are in milliseconds.)

The minTimeout and maxTimeout are per each request, i.e. the graphing cache will keep the graphs for each request for minTimeout amount of time. So if there are 4 graphs in one page then request for the page arrives at lets say 1'o clock and the min timeout is 5 secs, then each graph for the request will be kept only in cache for 1'o clock + time to generate graph + minTimeout. So a problem could be if the last graph takes lets say 10 secs to generate, then by the time it is ready all the previous graphs will timeout and will be removed from the cached.

This can create a problem when:


  1. There are a large number of charts one page (> 200). In this case, some charts will be drawn but remaining charts will display the error message

  2. There are only a few charts on a page but some charts take more than minTimeOut amount of time to generate in this case the remaining charts will not be generated and the error message will be thrown.

Wednesday, June 24, 2009

Start ESX or ESXi Guests at Boot

I've had to do this before and always forget, so here goes.
  1. Launch the VIC
  2. Click on the server icon (not the guest icon)
  3. Click the "Configuration" tab
  4. Click on Virtual Machine startup/shutdown
  5. Click on "Properties"
  6. Click on "allow virtual machines to start and stop with the system"
  7. Click on the guest you want to start automatically and then click "move up" until it's in the 'Automatic Start Up' section
  8. Rinse, repeat for any other guests OS's

The last few steps are not very intuitive, but you get the idea once you've done it a few times. Thanks to Merrick for reminding me which tab these settings were on. I had to do this a few months ago and had forgotten.

Friday, April 24, 2009

Streaming Flash Video in 2003 (IIS6)

I don't know how many times I've come across this problem and remembered what the issue was, but not the solution. Scenario: Windows 2003 with IIS6. You have a page with an fla file that plays an flv video, but the video won't show up. Issue: IIS is missing the correct MIME type for FLV videos. Solution:
Open IIS Manager on the server:
  1. Expand the Local Computer Server.
  2. Right mouse click and choose 'Properties' of the local server
  3. Select the MIME Types tab.
  4. Click the 'New' button and enter the following:
    Associated Extension box: .FLV
    MIME Type box: flv-application/octet-stream
  5. Click Ok and restart IIS.
Update: This same solution can be used if the file you are streaming is an mp4 file. Mime type: video/mpeg

Monday, April 20, 2009

Expanding a Virtual Drive in VMWare Workstation

David Merrick and I ran into an issue today growing a windows 2003 WMWare disk partition running on VMWare workstation. Apparently, you cannot use the GUI tools in Workstation to increase the size of vmdx files. However, you *can* use the command line:

vmware-vdiskmanager -x 12GB “Windows Server 2003 Standard Edition.vmdk”

Where 12GB is the new size of the disk. Make sure you do this from the VMWare Workstation install directory.

Check out David's blog post on this for more details. After that, we used PMagic to inflate the partition to the new drive size.

Thursday, April 16, 2009

Can't Undo in Dreamweaver CS3

A few days ago Dreamweaver CS3 stopped allowing me the ability to undo things whether I was in code view or design view. I thought maybe restarting DWCS3 would fix it, but to no avail. I did some googling and found a post where people were saying you needed to delete the FileCache.dat file in the Macromedia application data folder for the user having the issue. This information did not hold so true for DW CS3, but it did lead me down the correct path.

My solution was to close DW and navigate to:

C:\Documents and Settings\<user>\Application Data\Adobe\Dreamweaver 9\Configuration

In there I found a file named: WinFileCache-AD76BB20.dat Your WinfileCache file might be named slightly different, but it's the only .dat file in that directory. Rename that file or delete it (I always err on the side of caution) and restart Dreamweaver.

Thursday, March 5, 2009

Creating a VMDK file indepedent of a Guest VM

So you've got your ESX or ESXi server set up with a bunch of guests. What if you wanted to share a drive between them independent of any particular guest os? You can use the command line tool vmkfstools to achieve this. Let's say you wanted to create a new virtual disk 3GB. Open up your command line and change to the directory you want your new virtual drive located in. Use the command:

vmkfstools -c 3000M ./file.vmdk

That's it. Now you can mount this as a drive on any of your VM guests. This is a good idea if you have a bunch of tools or installs you use on a variety of systems. Unfortunately, you cannot share the vmdk file on multiple guest vm's at the same time.

Resources:
http://searchvmware.techtarget.com/tip/0,289483,sid179_gci1348873,00.html
http://www.esxguide.com/esx/content/view/18/25/