<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Lynch Consulting Blog - Database</title>
			<link>http://www.lynchconsulting.com.au/blog/index.cfm</link>
			<description>A blog about ColdFusion, PHP, Flash, Flex, Web Standards and a mish mash of other technologies</description>
			<language>en-us</language>
			<pubDate>Tue, 07 Sep 2010 12:55:24 --1000</pubDate>
			<lastBuildDate>Fri, 29 Jan 2010 08:15:00 --1000</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>mark@lynchconsulting.com.au</managingEditor>
			<webMaster>mark@lynchconsulting.com.au</webMaster>
			
			
			
			
			
			<item>
				<title>MySQL 5.1 logging changes - Log to DB and runtime config</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2010/1/29/MySQL-51-logging-changes</link>
				<description>
				
				While browsing around the MySQL site last night I discovered a number of nice new features of mysql 5.1 that relate to logging.

These are:

&lt;ul&gt;
&lt;li&gt;Logging to DB instead of log files&lt;/li&gt;
&lt;li&gt;Runtime configuration of logging.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Logging to DB instead of log files&lt;/h3&gt;

Coming from a web development background rather than a sysadmin background I&apos;m far more comfortable manipulating and analysing data using SQL.  So to be able to log all the queries or just the slow queries for an application to the db during application development or load testing is a huge benefit.

To enable logging to DB you can add the following to your my.cnf
&lt;code&gt;
log_output = TABLE
&lt;/code&gt; 

The logs will be written to the &apos;slow_log&apos; and &apos;general_log&apos; tables in the mysql database.

Note - logging to tables has more overhead than logging to file, so would suggest using it primarily for development purposes.

Full details of the options are on the &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.1/en/log-tables.html&quot;&gt;mysql manual on log tables&lt;/a&gt;


&lt;h3&gt;Runtime configuration of logging.&lt;/h3&gt;

This allows you to turn on and off logging without restarting MySQL - which just saves a little bit of time and makes it much nicer for debugging problems.

To turn on the logging of all queries run:
&lt;code&gt;
SET GLOBAL general_log = &apos;ON&apos;;
&lt;/code&gt;
And for just the slow query log:
&lt;code&gt;
SET GLOBAL slow_query_log = &apos;ON&apos;;
&lt;/code&gt;

And to turn them both off use:
&lt;code&gt;
SET GLOBAL general_log = &apos;OFF&apos;;
SET GLOBAL slow_query_log = &apos;OFF&apos;;
&lt;/code&gt;

If you also want to see queries not using indexes in the slow query log you can set the following variable:

&lt;code&gt;
SET GLOBAL log_queries_not_using_indexes = &apos;ON&apos;;
&lt;/code&gt;


Hope it helps,
Mark
				
				</description>
				
				<category>Ubuntu</category>
				
				<category>Systems admin</category>
				
				<category>Open Source</category>
				
				<category>mysql</category>
				
				<category>Linux</category>
				
				<category>Database</category>
				
				<pubDate>Fri, 29 Jan 2010 08:15:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2010/1/29/MySQL-51-logging-changes</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Identifying which queries to tune with MSSQL</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/4/Identifying-which-queries-to-tune-with-MSSQL</link>
				<description>
				
				I&apos;ve been doing some more work tuning and CF/MSSQL application and during figuring out which parts of the system is doing the most work (and hence a good candidate for tuning) I came across this gem which will show stats on the most run queries in the cache.

&lt;code&gt;
SELECT TOP 20 SUBSTRING(qt.text, (qs.statement_start_offset/2)+1, 
        ((CASE qs.statement_end_offset
          WHEN -1 THEN DATALENGTH(qt.text)
         ELSE qs.statement_end_offset
         END - qs.statement_start_offset)/2)+1), 
qs.execution_count, 
qs.total_logical_reads, qs.last_logical_reads,
qs.min_logical_reads, qs.max_logical_reads,
qs.total_elapsed_time, qs.last_elapsed_time,
qs.min_elapsed_time, qs.max_elapsed_time,
qs.last_execution_time,
qp.query_plan
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
WHERE qt.encrypted=0
ORDER BY qs.total_logical_reads DESC
&lt;/code&gt;

I found it in this &lt;a href=&quot;http://technet.microsoft.com/en-us/magazine/2007.11.sqlquery.aspx&quot;&gt;excellent article on optimising MSSQL&lt;/a&gt;

The times that are returned from the queries are in micro seconds as &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms189741.aspx&quot;&gt;documented on msdn&lt;/a&gt;.

Cheers,
Mark
				
				</description>
				
				<category>ColdFusion</category>
				
				<category>Systems admin</category>
				
				<category>Database</category>
				
				<pubDate>Wed, 04 Feb 2009 11:29:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/4/Identifying-which-queries-to-tune-with-MSSQL</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Clear MSSQL Query Caches</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/3/Clear-MSSQL-Query-Caches</link>
				<description>
				
				Found this useful little snippet for when you are load testing MSSQL Servers.

You can use it to clear the query cache - to ensure you are starting from a level playing field.  Or if you are tuning queries in a application and want to ensure they are not cached run it before each run:

&lt;code&gt;
dbcc freeproccache
go
dbcc dropcleanbuffers
go
&lt;/code&gt;

Cheers,
Mark
				
				</description>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>Windows</category>
				
				<pubDate>Tue, 03 Feb 2009 22:12:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/3/Clear-MSSQL-Query-Caches</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Loading MySQL timezone info on Linux and Macs</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/9/8/Loading-MySQL-timezone-info-on-Linux-and-Macs</link>
				<description>
				
				MySQL has some really useful functions that make timezone support a bit easier &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/index.cfm/2007/4/29/CFMX-applications-on-servers-with-different-time-zones&quot;&gt;as described in a previous blog post.&lt;/a&gt;.

However, you need to do a tiny bit of setup work before you can use the functions.  You need to load the timezone info from your system into the mysql db.

Thankfully, the MySQL Developers have included a very handy script that will do just that from a zoneinfo files which are used on Linux and on Mac&apos;s.

&lt;code&gt;
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
&lt;/code&gt;

Obviously change the mysql params or add a -p if you have a password or are connecting to a remote server.

Check out the MySQL developer site for &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html&quot;&gt;full details on MySQL timezone support&lt;/a&gt;

Cheers,
Mark
				
				</description>
				
				<category>mysql</category>
				
				<category>Mac OSX</category>
				
				<category>Linux</category>
				
				<category>Database</category>
				
				<category>Open Source</category>
				
				<pubDate>Mon, 08 Sep 2008 13:30:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/9/8/Loading-MySQL-timezone-info-on-Linux-and-Macs</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>MySQL and Temporary tables and CASE syntax</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/8/31/MySQL-and-Temporary-tables-and-CASE-syntax</link>
				<description>
				
				For some reason I&apos;ve always avoided the use of temporary tables in SQL (MySQL or otherwise) but today I came across a difficult problem that temporary tables made very simple.  

I needed to use a case function on a subquery value to return a tri-state value.  I.e. yes, no or partial.

The cut down query below demonstrates how it works.

&lt;ul&gt;
&lt;li&gt;First we drop the temporary table in case one has been left lying around.&lt;/li&gt;
&lt;li&gt;Then we select a query into the temporary table which include some complex subqueries.&lt;/li&gt;
&lt;li&gt;We can then query the temporary table to do further processing on the result, which in this case depending on the values of the class_count and class_count_assigned allows us to set a field in three states.
&lt;ul&gt;
&lt;li&gt;&apos;yes&apos; if all users for a class are selected&lt;/li&gt;
&lt;li&gt;&apos;partial&apos; if some users are selected&lt;/li&gt;
&lt;li&gt;&apos;no&apos; if none are selected.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;code&gt;
&lt;cfquery name=&quot;q&quot; datasource=&quot;#variables.myDSN#&quot;&gt;
	DROP TEMPORARY TABLE  IF EXISTS tmp_exams;
	/* Create temporary table query which includes student counts */
	CREATE TEMPORARY TABLE tmp_exams
	SELECT	e.id
			, e.name
			, (SELECT count(1) FROM tbl_user_classes uXc
                WHERE uXc.school_class_id = &lt;cfqueryparam value=&quot;#arguments.school_class_id#&quot; cfsqltype=&quot;cf_sql_integer&quot;&gt;) AS class_count
            , (SELECT count(1) FROM tbl_user_classes uXc
                INNER JOIN  tbl_users_exams uXe ON uXe.user_id = uXc.user_id
                WHERE uXc.school_class_id = &lt;cfqueryparam value=&quot;#arguments.school_class_id#&quot; cfsqltype=&quot;cf_sql_integer&quot;&gt;
                AND exam_id = e.id) AS class_count_assigned
	FROM	tbl_exams e;
	/* Select out the relevant info */
	SELECT e.id
			, e.name
			, e.class_count
			, e.class_count_assigned
		    ,(CASE WHEN class_count_assigned = 0 THEN &apos;no&apos;
		    	WHEN class_count = class_count_assigned THEN &apos;yes&apos;
		    	ELSE &apos;partial&apos; END) AS active
	FROM tmp_exams e
	WHERE	1=1
	ORDER BY e.name
&lt;/cfquery&gt;
&lt;/code&gt;

Mostly posted for my future reference but hope it helps out.

Cheers,
Mark
				
				</description>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>mysql</category>
				
				<pubDate>Sun, 31 Aug 2008 20:47:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/8/31/MySQL-and-Temporary-tables-and-CASE-syntax</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>PHP and MySQL 5 bit fields</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/8/25/PHP-and-MySQL-5-bit-fields</link>
				<description>
				
				While debugging some PHP code the other night I came across a particularly strange problem with MySQL Bit fields.

I was returning a query with some bit fields into my class but the it was not returning true or false when I switched the data.

A bit of hunting and it turned out the that it was being returned as a binary type and after a few failed attempts to convert it to an integer or boolean on the PHP side I found &lt;a href=&quot;http://pear.php.net/bugs/bug.php?id=10211&quot;&gt;this bug report on it&lt;/a&gt;.

So the moral of the story is if you are selecting BIT types from a mysql DB in PHP don&apos;t do this:

&lt;code&gt;
 SELECT myBit
 FROM tbl_example
 WHERE id = 1
&lt;/code&gt;

Instead cast the bit to an integer in MySQL like so:
&lt;code&gt;
 SELECT CAST(myBit AS unsigned integer) AS myBit, 
 FROM tbl_example
 WHERE id = 1
&lt;/code&gt;

Voila, it works like expected.

Cheers,
Mark Lynch
				
				</description>
				
				<category>Open Source</category>
				
				<category>mysql</category>
				
				<category>Database</category>
				
				<category>PHP</category>
				
				<pubDate>Mon, 25 Aug 2008 12:21:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/8/25/PHP-and-MySQL-5-bit-fields</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>&quot;Show Full Columns&quot; problem with CFMX and MySQL solved</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/1/Show-Full-Columns-problem-with-CFMX-and-MySQL-solved</link>
				<description>
				
				We&apos;ve been performing some load testing on a new website we&apos;ve developed and our helpful sysadmin noticed lots of queries happening on the DB that looked like this:

&lt;code&gt;
SHOW FULL COLUMNS FROM `dbname`.`tablename`
&lt;/code&gt;

We weren&apos;t intentionally doing these queries but they were coming from somewhere.  A bit of detective work via google found &lt;a href=&quot;http://whirlpool.net.au/blog/5 &quot;&gt; a very enlightening article about this problem&lt;/a&gt;.

A quick read of this explained: 
&lt;blockquote&gt;
It turns out ColdFusion was asking Connector/J for the metadata on every field, which in turn triggered a SHOW FULL COLUMNS query for every varchar and text column returned.
&lt;/blockquote&gt;

It also went on to say that is had been &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/cj-news-5-0-7.html&quot;&gt;fixed as of Connector/J 5.07&lt;/a&gt;.

On reading the release notes it mentions that the
&lt;blockquote&gt;
Driver detects when it is running in a ColdFusion MX server (tested with version 7), and uses the configuration bundle coldFusion, which sets useDynamicCharsetInfo to false (see previous entry), and sets useLocalSessionState and autoReconnect to true. 
&lt;/blockquote&gt;

However, from my testing it wasn&apos;t doing it as we were still seeing the problem.  However, we are running the MultiServer version of ColdFusion which sits atop Jrun4.

So I added the parameter directly to the querystring:
&lt;code&gt;
&amp;useDynamicCharsetInfo=false
&lt;/code&gt;
So it now looks like:
&lt;code&gt;
jdbc:mysql://127.0.0.1:3306/mydbname?allowMultiQueries=true&amp;useDynamicCharsetInfo=false
&lt;/code&gt;

This has stopped the problem, and given a significant performance gain.  On one of the sites I was load testing it gave a 12% throughput increase and on another one which had less queries it gave a 4% increase.

Hope it helps.

Cheers,
Mark
				
				</description>
				
				<category>Open Source</category>
				
				<category>mysql</category>
				
				<category>Java</category>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>Systems admin</category>
				
				<pubDate>Sun, 01 Jun 2008 21:01:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/1/Show-Full-Columns-problem-with-CFMX-and-MySQL-solved</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CF 7.0.2 Cumulative Hotfix 2 breaks MySQL Multiple Queries</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/4/23/CF-702-Cumulative-Hotfix-2-breaks-MySQL-Multiple-Queries</link>
				<description>
				
				I&apos;ve just spent a while figuring out a painful bug in CF and am posting here so that I can reference it from the Adobe bug tracker as I can&apos;t explain the problem in 2000 characters.

&lt;h2&gt;Summary of Problem&lt;/h2&gt;

CF 7.0.2 Cumulative Hotfix 2 and 3 breaks the use of Multiple SQL statements with MySQL connectorJ connector.

This is a regression as it works perfectly in CF 7.0.2 and CF 7.0.2 with Cumulative hotfix 1.

I have tested the following configurations:
&lt;ul&gt;
&lt;li&gt;CF7.0.2 MySQL connectorJ 5.0.8  - works&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 1 MySQL connectorJ 5.0.8  - works&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 2 MySQL connectorJ 5.0.8  - broken&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 3 MySQL connectorJ 5.0.8  - broken&lt;/li&gt;
&lt;li&gt;CF7.0.2 MySQL connectorJ 3.1.10  - works&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 1 MySQL connectorJ 3.1.10  - works&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 2 MySQL connectorJ 3.1.10  - broken&lt;/li&gt;
&lt;li&gt;CF7.0.2 hotfix 3 MySQL connectorJ 3.1.10  - broken&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Steps to reproduce bug:&lt;/h2&gt;


1. Set up a CF 7.0.2 Multiserver install with built in webserver

2. Download and install ConnectorJ JDBC driver for MySQL and install as per Adobe Technote &lt;a href=&quot;http://www.adobe.com/go/6ef0253&quot;&gt;http://www.adobe.com/go/6ef0253&lt;/a&gt;

3. Create a mysql database named &quot;test&quot; the and create a table with the following script:

&lt;code&gt;
CREATE TABLE `tbl_test` ( 
	`id`  	int(11) AUTO_INCREMENT NOT NULL,
	`data`	varchar(50) NULL,
	PRIMARY KEY(`id`)
)
&lt;/code&gt;

4. In CF Admin create a DSN named dsn_test with following settings
&lt;ul&gt;
&lt;li&gt;JDBC Url: jdbc:mysql://127.0.0.1:3306/test?allowMultiQueries=true&lt;/li&gt;
&lt;li&gt;Driver Class: com.mysql.jdbc.Driver&lt;/li&gt;
&lt;li&gt;Driver name: (leave blank)&lt;/li&gt;
&lt;li&gt;username: (valid user for your db - default: root)&lt;/li&gt;
&lt;li&gt;password: (valid password for your db - default: &apos;blank&apos;)&lt;/li&gt;
&lt;li&gt;Place the following file in the /opt/jrun4/servers/cfusion/cfusion-ear/cfusion-war directory&lt;/li&gt;
&lt;/ul&gt;
 

&lt;code&gt;
MySQL driver version:
&lt;cftry&gt;
&lt;cfset oDriver = createObject(&quot;java&quot;,&quot;com.mysql.jdbc.Driver&quot;)&gt;
&lt;cfoutput&gt; #oDriver.getMajorVersion()#.#oDriver.getMinorVersion()#&lt;/cfoutput&gt;
&lt;cfcatch type=&quot;any&quot;&gt;
	Unknown
&lt;/cfcatch&gt;
&lt;/cftry&gt;

&lt;cfquery name=&quot;qTest&quot; datasource=&quot;dsn_test&quot;&gt;
	INSERT INTO tbl_test (data)
	VALUES (&apos;Test String&apos;);
	SELECT LAST_INSERT_ID() as lastInsertID;
&lt;/cfquery&gt;
&lt;cftry&gt;
&lt;cfdump var=&apos;#qTest#&apos;&gt;
&lt;cfcatch type=&quot;any&quot;&gt;
	No Query set returned from query.
&lt;/cfcatch&gt;
&lt;/cftry&gt;
&lt;/code&gt;

This code should function correctly and return a cfdump of the auto generated primary key as per &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/expected.png&quot;&gt;expected screenshot&lt;/a&gt;. 


Next apply Coldfusion Cumulative hotfix 2 and restart coldfusion as per Adobe Technote  http://www.adobe.com/go/kb400996


Re run the test and no query set will be returned from the driver.  The qTest variable does not get set as per the  &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/broken.png&quot;&gt;broken screenshot&lt;/a&gt;. 


&lt;h2&gt;Related Resources&lt;/h2&gt;
Technote re upgrading MySQL JDBC Drivers &lt;a href=&quot;http://www.adobe.com/go/6ef0253&quot;&gt;http://www.adobe.com/go/6ef0253&lt;/a&gt;


CF Updates page &lt;a href=&quot;http://www.adobe.com/support/coldfusion/downloads_updates.html#mx7&quot;&gt;http://www.adobe.com/support/coldfusion/downloads_updates.html#mx7&lt;/a&gt;


CF 7.0.2 Cumulative hot 3 &lt;a href=&quot;http://www.adobe.com/go/kb402465&quot;&gt;http://www.adobe.com/go/kb402465&lt;/a&gt;


CF 7.0.2 Cumulative hot 2 &lt;a href=&quot;http://www.adobe.com/go/kb400996&quot;&gt;http://www.adobe.com/go/kb400996&lt;/a&gt;


CF 7.0.2 Cumulative hot 1 &lt;a href=&quot;http://www.adobe.com/go/kb400074&quot;&gt;http://www.adobe.com/go/kb400074&lt;/a&gt;


MySQL ConnectorJ &lt;a href=&quot;http://www.mysql.com/products/connector/j/&quot;&gt;http://www.mysql.com/products/connector/j/&lt;/a&gt;


MySQL ConnectorJ 3.1.10 Download: &lt;a href=&quot;http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.10.tar.gz/from/pick#mirrors&quot;&gt;http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.10.tar.gz/from/pick#mirrors&lt;/a&gt;
				
				</description>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>mysql</category>
				
				<pubDate>Wed, 23 Apr 2008 13:40:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/4/23/CF-702-Cumulative-Hotfix-2-breaks-MySQL-Multiple-Queries</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Multiple queries with CFMX-MySQL JDBC connector</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/2/10/Multiple-queries-with-CFMXMySQL-JDBC-connector</link>
				<description>
				
				I found a little snippet the other day and included it in the tail end of a previous post - however, on reflection I thought it deserved a post of it&apos;s own.

If you want to utilise multiple queries per sql statement and you are using the MYSQL JDBC connector you need to add the following to your jdbc connector querystring.
&lt;code&gt;
allowMultiQueries=true
&lt;/code&gt;
So you querystring would look like:
&lt;code&gt;
jdbc:mysql://127.0.0.1:3306/mydbname?allowMultiQueries=true
&lt;/code&gt;

This will allow you to do queries like the following to return autoincrement values:
&lt;code&gt;

&lt;cfquery name=&quot;qInsert&quot; datasource=&quot;mydsn&quot;&gt;
 INSERT INTO tbl_demo (name)
 VALUES ( &lt;cfqueryparam value=&quot;#myName#&quot;&gt;);
 SELECT last_insert_id() as newID
&lt;/cfquery&gt;
&lt;cfoutput&gt;ID of value is: #qInsert.newID#&lt;/cfoutput&gt;

&lt;/code&gt;

Please note however that this functionality is disabled as it can leave the door open for SQL Injection attacks.  However, as long as you always use cfqueryparam for all the dynamic parts of your query you will be fine.
				
				</description>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>mysql</category>
				
				<pubDate>Sun, 10 Feb 2008 21:32:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/2/10/Multiple-queries-with-CFMXMySQL-JDBC-connector</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFMX Mysql Query String for UTF8 and Multiple Queries</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/2/7/CFMX-Mysql-Query-String-for-UTF8-and-Multiple-Queries</link>
				<description>
				
				While testing some of the code we&apos;ve written for UTF8 support for double byte characters (Chinese, Japanese, Malaysian) I discovered that there are some voodoo JDBC connection string parameters that have to be set to make it work.

Firstly, CFMX used UTF8 by default so it&apos;s already configured. You need to make sure that your MySQL DB table has a Charset of utf8 as per example below:

&lt;code&gt;
CREATE TABLE `utf8test` ( 
	`id`     	int(11) NOT NULL,
	`data`    	varchar(25) NULL,
	PRIMARY KEY(`id`)
)CHARACTER SET utf8 COLLATE utf8_general_ci;
&lt;/code&gt;

Then you need to add the following params to the connection string:
&lt;ul&gt;
&lt;li&gt;characterEncoding=UTF8&lt;/li&gt;
&lt;li&gt;characterSetResults=UTF8&lt;/li&gt;
&lt;/ul&gt;

I also add the &quot;allowMultiQueries=true&quot; string which allows you to execute multiple queries in the one statement.  It is disabled by default as it can open up a window for SQL Injection attacks, but this can be mitigated by always using CFQUERYPARAM&apos;s.

So the final connection string looks like this:
&lt;code&gt;
jdbc:mysql://127.0.0.1:3306/utf8demo?allowMultiQueries=true&amp;characterEncoding=UTF8&amp;characterSetResults=UTF8
&lt;/code&gt;

Hope it helps,
Cheers,
Mark
				
				</description>
				
				<category>mysql</category>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>Open Source</category>
				
				<pubDate>Thu, 07 Feb 2008 12:56:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/2/7/CFMX-Mysql-Query-String-for-UTF8-and-Multiple-Queries</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Cross platform Database IDE</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2007/9/15/Cross-platform-Database-IDE</link>
				<description>
				
				Ever since I&apos;ve moved to using Linux full time I&apos;ve been looking for a solid Database IDE. I&apos;ve tried and tested quite a few.

&lt;dl&gt;
&lt;dt&gt;&lt;a href=&quot;http://www.aquafold.com/&quot;&gt;Aqua Data Studio&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;This is my current DB IDE of choice and has some significant features in the new &lt;a href=&quot;http://docs.aquafold.com/ads/6.5/features_6_5.html&quot;&gt;version 6.5&lt;/a&gt; that means I&apos;ll be staying with it for a while, particularly as it runs on Linux, Macs and Windows identically.&lt;/dd&gt;
&lt;dd&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.aquafold.com/ads/6.5/features_6_5.html#schemaCompare&quot;&gt;Schema Comparison&lt;/a&gt; - very handy for keeping development and production db&apos;s schemas in sync.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.aquafold.com/ads/6.5/features_6_5.html#pivotresults&quot;&gt;Charts &amp; Pivot Tables&lt;/a&gt; - makes it easy to create adhoc graphs withouth having to resort to Excel/OpenOffice Calc&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.aquafold.com/ads/6.5/features_6_5.html#morphtolist&quot;&gt;Morph to Delimited List&lt;/a&gt; - A simple but powerful function that saves a lot of time. Allows you to take the results of a sql query and convert to comma seperated list.  I&apos;ve done dozens of adhoc CF scripts to handle this before :-)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.aquafold.com/ads/6.5/features_6_5.html#subversion&quot;&gt;Subversion Support&lt;/a&gt; - As we use subversion for our code it&apos;s handy to have it built in.&lt;/li&gt;
&lt;/ul&gt;

&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;http://dev.mysql.com/downloads/gui-tools/&quot;&gt;MySQL GUI tools&lt;/a&gt; (Query Browser &amp; Admin)&lt;/dt&gt;
&lt;dd&gt;These have some very nice functionality but have always found them to be pretty unstable - they just crash a lot with no explanation.&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;http://www.navicat.com/&quot;&gt;Navicat&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;This is pretty good option, but the Linux version is the poor cousin to the Windows &amp;amp; Mac versions.&lt;/dd&gt;

&lt;/dl&gt;

Love to hear any comments feedback or suggestions.
				
				</description>
				
				<category>Systems admin</category>
				
				<category>Open Source</category>
				
				<category>Java</category>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>Windows</category>
				
				<pubDate>Sat, 15 Sep 2007 05:29:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2007/9/15/Cross-platform-Database-IDE</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Compare db&apos;s with DB Diff tool for CFMX</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2007/7/19/Compare-dbs-with-DB-Diff-tool-for-CFMX</link>
				<description>
				
				As a cf developer I have lots of tools for managing source code with &lt;a href=&quot;http://subversion.tigris.org&quot;&gt;excellent version control systems&lt;/a&gt;, &lt;a href=&quot;http://www.cfeclipse.org&quot;&gt;cfeclipse&lt;/a&gt;, and the luxury of dev, staging and production environments for code.


&lt;img src=&quot;http://www.lynchconsulting.com.au/blog/enclosures/DBDiff-Screenshot.png&quot; align=&quot;right&quot;&gt;
Despite all these tools, one area that can be difficult to manage is changes to database schema&apos;s as applications evolve.

For example - as there are seperate dev, staging and production db&apos;s you need to be meticulous in scripting all changes and remembering to apply all changes across all db&apos;s at appropriate times.

I&apos;ve been reading about how Ruby on Rails manages db changes with &quot;Migrations&quot; which seem like a pretty good solution but they have significant limits and are not perfect solution.

In my ongoing quest to make my life easier I wanted a tool which could tell me the difference between two databases - eg dev and staging db&apos;s - and save me having to check each table and row.  


Initially I used mysqldump and a diff tool to see the differences - which worked a treat but was a lot of repetitive steps to get the report I needed.   Perfect for some automation.  After a bit of searching I found a &lt;a href=&quot; http://cfdiff.googlecode.com/&quot;&gt;CFMX diff cfc &lt;/a&gt; by Rick Osborne which was allowed me to very simply create a super simple Datasource compare tool as shown in the screenshot.

I can now quickly compare the different db&apos;s by setting up datasources on my machine for each one, and ensure that they are always in a consistent state.

&lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/dbdiff-0.1.zip&quot;&gt;Download it&lt;/a&gt;, give it a spin and let me know if it&apos;s any use.  Note that it only works in MySQL 5 at the moment, but would likely be simple to port to other dbs.

Also very happy to hear if anyone has better solutions or processes for keeping DB&apos;s in sync.

Cheers,
Mark
				
				</description>
				
				<category>Open Source</category>
				
				<category>Database</category>
				
				<category>ColdFusion</category>
				
				<category>Systems admin</category>
				
				<pubDate>Thu, 19 Jul 2007 10:30:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2007/7/19/Compare-dbs-with-DB-Diff-tool-for-CFMX</guid>
				
			</item>
			
		 	
			</channel></rss>